## Fizz Coke

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Java 1.2s
Memory limit: 64M
PyPy 2 128M
PyPy 3 128M

Author:
Problem type

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 and version. He is now sitting in the washroom, asking you for help. Can you help him?

#### Constraints

It is guaranteed that all will be unique.

All words are between and characters in length, inclusive, and only contain uppercase and lowercase letters.

All will be in increasing order.

#### Input Specification

The first line contains two space-separated integers, and .

The next lines contain and separated by a space.

#### 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