#P2203. [USACO13OPEN] Blink B

[USACO13OPEN] Blink B

Description

Farmer John is unhappy with the dim lighting on the farm, so he has just installed a beautifully decorated new chandelier. This chandelier consists of N(3N16)N(3 \le N \le 16) lamps arranged in a circle.

The cows are fascinated by this new light device. They like to play the following game: at time TT, for each lamp ii, if at time T1T-1 the lamp to its left (if i1i\not=1 then i1i-1; if i=1i=1, then NN) is on, then toggle the state of lamp ii; otherwise, do nothing.

They will keep performing this operation for B (1B1015)B\ (1 \le B \le 10^{15}) units of time. Please note that BB may exceed the range of a typical 32-bit integer.

Given the initial state of each lamp, compute the state of each lamp after BB units of time.

Input Format

Line 1: Two integers NN and BB.

Lines 2N+12\sim N+1: Line i+1i+1 describes the initial state of lamp ii, represented by 0 (off) or 1 (on).

Output Format

NN lines. On line ii, output a single integer representing the final state of lamp ii, using 0 (off) or 1 (on).

5 6
1
0
0
0
0
1
1
1
0
1

Hint

Sample Explanation

Below is a simulation of the sample output:

Time T=0: 1 0 0 0 0
Time T=1: 1 1 0 0 0
Time T=2: 1 0 1 0 0
Time T=3: 1 1 1 1 0
Time T=4: 1 0 0 0 1
Time T=5: 0 1 0 0 1
Time T=6: 1 1 1 0 1

Translated by ChatGPT 5