Time Limit: 1s
Memory Limit: 512MB
Farmer John installed N lights bulbs which are arranged in a circle.
At time T, Bessie toggle the state of each light bulb if its neighbor to the left was turned on at time T-1. She plays the game for M units of time.
Given the initial states of the light bulbs, output their final states after M units of time.
Line 1: N and M, 3<=N<=16, 1<=M<=10^15
Line 2..N+1:the initial state of bulb i, either 0(off) or 1(on)
N lines, their final states after M units of time.
5 6 1 0 0 0 0
1 1 1 0 1
T=0: 1 0 0 0 0
T=1: 1 1 0 0 0
T=2: 1 0 1 0 0
T=3: 1 1 1 1 0
T=4: 1 0 0 0 1
T=5: 0 1 0 0 1
T=6: 1 1 1 0 1