#B4106. Coin Flip Sequence

    ID: 11763 Type: Default 1000ms 256MiB

Coin Flip Sequence

Coin Flip Sequence

You are given \( n \) coins placed in a row, numbered from \( 1 \) to \( n \). Each coin shows heads (represented by \( 0 \)) initially and tails (represented by \( 1 \)) when flipped.

There are \( m \) operations. In the \( i \)-th operation, you are given an interval \( [l_i, r_i] \). For each coin in that interval, flip it: if it is \( 0 \) it becomes \( 1 \), and vice versa.

After performing all the operations, output the final sequence of \( 0 \)'s and \( 1 \)'s (from left to right) representing the coin states.

inputFormat

The first line contains two integers \( n \) and \( m \) representing the number of coins and the number of operations respectively.

Each of the next \( m \) lines contains two integers \( l_i \) and \( r_i \) indicating the range of coins to flip.

outputFormat

Output a single line containing a string of \( n \) characters, each character is either \( 0 \) or \( 1 \), representing the state of the coins from left to right after all operations.

sample

5 2
1 3
2 4
10010