You are given an infinite array of zeros with positions indexed by the integers and intervals of positions of the form . For every given interval, you have to use one of the following two operations to execute on the array:
- Normal: Add to all positions in the array from to .
- Flipped: Add to all positions in the array except those from to .
Task
You want to choose a type of operation to execute for each interval so that the maximum value stored in the array after applying all operations is minimized.
Input data
The first line of the input contains the number of intervals . The next lines each contain two space-separated integers, and , representing the endpoints of an interval.
Output data
The first line of the output should contain the maximum value in the array after executing the operations optimally.
The second line should contain a binary string of length , with the th character being if the th used operation was flipped and if it was normal.
If there are multiple ways of choosing the operations optimally, any valid solution is accepted.
Constraints and clarifications
# | Points | Restrictions |
---|---|---|
1 | 7 | |
2 | 24 | |
3 | 21 | |
4 | 34 | |
5 | 14 | No further restrictions. |
Example
stdin
5
10 10
6 6
1 7
2 5
2 7
stdout
2
11110
Explanations
Another valid answer would be
2
11011