printРабочее место участника

printЗадачи

1850. Dividing into Groups

Ограничения: время – 1s/2s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Set of natural numbers must be divided into `G` groups so, that numbers `n`, `2*n`, …, `G*n` correspond to different groups, where `n` is arbitrary natural number.
Input
The first line of the input file contains two integers `M` and `G`, separated by a space, where `M` is the quantity of numbers in the file (`1\ ≤\ M\ ≤\ 10^6`) and `G` is the quantity of groups (`2\ ≤\ G\ ≤\ 5`). The following `M` lines contain a single integer `n` in a line (`1\ ≤\ n\ ≤\ 10^9`).
Output
Write into the output file `M` lines with numbers of groups for all numbers of the input file. If `i`-th number of the input file corresponds to `k`-th group while dividing into `G` groups, then on `i`-th line of the output file there should be the number `k` (`1\ ≤\ k\ ≤\ G`).

Sample Input

5 2
1
2
3
4
6

Sample Output

1
2
1
1
2
loading