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.
The first line contains
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.
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.
70 10 3