#P15514. [BalticOI 2003] Lamps (Day 2)

[BalticOI 2003] Lamps (Day 2)

题目描述

There is a castle with a circular main hall. There are NN lamps numbered from 11 to NN on the wall of the hall. Each of the lamps can be either on or off. At each second the lamp number ii changes its state if the lamp number i+1i+1 is on, except the lamp number NN changes its state if the lamp number 11 is on.

Your task is, given the initial states of all lamps at some moment, to find their states after MM seconds.

输入格式

The first line of the input contains two integers N (0<N106)N\ (0 < N \le 10^6) and M(0M109)M (0 \le M \le 10^9). The next NN lines contain the initial states of the lamps, starting with the lamp number 11. A line containing 00 means that the lamp is off and 11 means that the lamp is on.

输出格式

The output must contain exactly NN lines describing the states of the lamps after MM seconds, starting with the lamp number 11.

3 1
0
0
1
0
1
1