FizzBuzz (Hardest)

Paul is sad because you have been able to outsmart him at his game of 2-rule FizzBuzz. He decides to make the game even harder than it was previously by making up as many rules as he wants. He has created R rules with a divisor X and a word to output when the rule is fulfilled. When multiple rules are applicable add the words together in the order that the rules are given. He has also decided that he can give you i values of N to evaluate.

Input Specification

The first line contains R and i separated by a space. The next line contains i numbers to evaluate separated by a space. The next R lines contains a value of X and a word to output for that rule.

Output Specification

Print out the results of Paul's rules on each value of N separated by newlines. If multiple rules are applicable add the rules together in the order that they are given. If none are applicable, print the number.

Example Input

3 370 10 32 Fizz5 Buzz7 Yeet

Example Output

FizzBuzzYeetFizzBuzz3

• Subtask 1: R=3, N<=10
• Subtask 2: R<10, N<20