Code To Get Her SOLUTIONS CMX1P03

Page Contents

Code To Get Her SOLUTIONS CMX1P03

Jiraiya, one of the Konohagakure’s Sanin, is out for a world visit for M months with his supporter Naruto Uzumaki, looking for information that would support his companions.

On his excursion, he finds a reality S (a string) each month. Additionally, he makes a rundown of a few women who can help him in his significant exploration for that month. Yet, he can meet precisely one of them toward the finish of month. To choose the one, he initially ascertains the score for every woman in his rundown. He characterizes score for every woman dependent on her name as:

“Complete number of aftereffects of certainty S, which are re-arranged words of the name, modulo 998244353”

Jiraiya meets the woman with the most elevated score. On the off chance that there are more than one women with the most elevated score, he meets the one whose name starts things out in his rundown. On the off chance that all names have score 0, at that point he can’t meet anybody.

Naruto realizes that this assignment will make his lord, Jiraiya, invest an excess of energy in figurings. Thus, he needs to assist his with acing by composing a program which can do the above assignment rapidly, so his lord can invest more energy in his preparation. He needs the program to ascertain the score for every woman in Jiraiya’s rundown, lastly print the outcome, for example the name of the woman whom Jiraiya will meet. On the off chance that Jiraiya can’t meet anybody, the outcome ought to be “No Research This Month” (without cites). Since Naruto isn’t acceptable at coding, he needs your group’s assistance to code this out.

Note:

An aftereffect is a succession that can be gotten from another arrangement by erasing a few or no components without changing the request for the rest of the components. Two aftereffects are viewed as various if the places of erased components (in the first string) are distinctive for both the aftereffects (Even if these two aftereffects seem to be comparable). For Example: If abb is the first string, at that point the aftereffects abdominal muscle and abdominal muscle will be viewed as various on the off chance that they speak to the positions {1,2} and {1,3} in the first string separately.

A re-arranged word of a string is any reworking of that string. For instance, for the sting abb, these strings are re-arranged words: abb, bab, bba.

Info

First line contains M, the quantity of months. Every month is depicted as follows:

First line contains a string S, speaking to the reality found in the month.

Second line contains a whole number N indicating the complete number of names in Jiraiya’s rundown for the month. N more lines follow.

ith line contains a string namei, for example the ith name in Jiraiya’s rundown. (for 1≤i≤N)

Yield

For every month, print N+1 lines:

ith line (for 1≤i≤N) ought to contain a solitary whole number indicating the score of ith woman in Jiraiya’s rundown.

(N+1)th line ought to contain the outcome as depicted in the difficult explanation.

Limitations

1≤M≤5

1≤|S|≤105

1≤N≤20

1≤|namei|≤|S|

S and namei contain lowercase English letter sets as it were.

Test Input

doyouknowvegetahasatail

kylie

disha

twentytwentyisalmostdone

lordfifth

gokuisunbeatable

kushina

Test Output

16

No Research This Month

No Research This Month

Clarification

first Month:

For kylie, these 2 aftereffects are re-arranged words:

ykeil (here e is from position 10).

ykeil (here e is from position 12).

Subsequently the score is 2mod998244353=2

Correspondingly, for disha, 4 aftereffects are re-arranged words, so the score is 4mod998244353=4.

Furthermore, for tsunade, 8 aftereffects are re-arranged words, so the score is 8mod998244353=8.

Out everything being equal, tsunade has a most extreme score, so Jiraya gets the opportunity to meet tsunade this month.

second Month:

The two women have a score of 0. So Jiraya doesn’t get the chance to meet anybody.

third Month:

No re-arranged word is workable for kushina, so her score is 0