P2203 [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(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 $T$, for each lamp $i$, if at time $T-1$ the lamp to its left (if $i\not=1$ then $i-1$; if $i=1$, then $N$) is on, then **toggle the state of lamp $i$**; otherwise, do nothing. They will keep performing this operation for $B\ (1 \le B \le 10^{15})$ units of time. Please note that $B$ may exceed the range of a typical 32-bit integer. Given the initial state of each lamp, compute the state of each lamp after $B$ units of time.

Input Format

Line 1: Two integers $N$ and $B$. Lines $2\sim N+1$: Line $i+1$ describes the initial state of lamp $i$, represented by `0` (off) or `1` (on).

Output Format

$N$ lines. On line $i$, output a single integer representing the final state of lamp $i$, using `0` (off) or `1` (on).

Explanation/Hint

### Sample Explanation Below is a simulation of the sample output: ```plain 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