As a new CS graduate, your friend has memorized the Fizz Buzz problem and has his first interview today. Unfortunately for him, the interviewer thought that Fizz Buzz was too easy. He has proposed a new version, as shown:
You are given a number
, the number of numbers you should check divisibility by, and , the number you should go up to. The next
lines will contain a number , and its associated word . Counting from
to , print the associated word(s) in increasing order of if the current number is divisible by any of the numbers ; otherwise, print the current number.
Your friend is panicking because he only memorized the
Constraints
It is guaranteed that all
All words
Subtask 1 [10%]
All
Subtask 2 [20%]
Subtask 3 [70%]
Input Specification
The first line contains two space-separated integers,
The next
Output Specification
Print the required sequence of words and numbers, with one item on each line.
Sample Input 1
2 10
2 Fizz
3 Coke
Sample Output 1
1
Fizz
Coke
Fizz
5
FizzCoke
7
Fizz
Coke
Fizz
Sample Input 2
3 7
2 Fizz
6 Pepsi
3 Coke
Sample Output 2
1
Fizz
Coke
Fizz
5
FizzCokePepsi
7
Comments