Your younger sibling got a new toy for Christmas: a set of balls, tracks, and switches!
A ball sculpture is a construction made out of said tracks and switches where a small ball is placed at the top of the sculpture and travels down the tracks to the bottom. In between the top and bottom of the sculpture, there are switches that control the path that the ball takes.
The switches are labelled from to in order of height from the top of the sculpture to the bottom. Each switch has two output tracks which each lead either to another switch further down in the sculpture, or go directly to the bottom of the sculpture. This is denoted by two values and where , where a value of represents the track going to the very bottom.
A switch can be in one of two states: or . If a ball arrives while it is in state , the ball goes down a track to , but if it is in state , it goes to . In either case, the state of the switch is flipped to the opposite state.
Initially, all switches are in state . Then, a sequence of balls are placed at the top of the sculpture, where the previous ball must reach the bottom of the sculpture before the next ball is placed.
Bored, your younger sibling asks you: what is the final state of all the switches after all balls reach the bottom?
Constraints
Input Specification
The first line contains two space-separated integers and .
lines follow; the -th one contains two space-separated integers .
Output Specification
Output digits on a single line, with the -th digit being the state of switch .
Sample Input 1
3 5
2 3
4 4
4 4
Output for Sample Input 1
110
Explanation for Output for Sample Input 1
The sequence of states is 000, 110, 011, 101, 000, 110.
Sample Input 2
4 11
5 2
5 3
5 4
5 5
Output for Sample Input 2
1101
Comments