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 3
70 10 3
2 Fizz
5 Buzz
7 Yeet


Example Output


FizzBuzzYeet
FizzBuzz
3


Subtask Specifications



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

  • Subtask 2: R<10, N<20

Comments
  • There are no comments.