More Things to Do
Limits: 2 sec., 256 MiB
As you already know, Zenyk has a lot of tasks to do. In total, he has NN tasks, ii-th of them will last from the time lili to riri. Note that the tasks can overlap or intersect in any way.
This time, Zenyk decided that he could move some of the tasks to tomorrow. Zenyk does not like much when tasks overlap, so he wants to break more such tasks between different days. Suppose intersect(a,b)intersect(a,b) is the length of the intersection of the tasks aa and bb. For example, intersect([2,7],[4,10])=3intersect([2,7],[4,10])=3, intersect([4,7],[2,10])=3intersect([4,7],[2,10])=3, intersect([2,4],[7,10])=0intersect([2,4],[7,10])=0. Suppose the set of tasks that Zenyk performs today is AA, tomorrow — BB.
Then Zenyk wants to maximize C=∑a∈A∑b∈Bintersect(a,b)C=∑a∈A∑b∈Bintersect(a,b).
Help him with this.
Input
The first line contains a single integer NN. In the following NN lines, there are given 2 integers lili and riri.
Output
In the first line, print the maximum value of CC. In the second line, print NN numbers 00 or 11. 11 means that Zenyk will do the task today, 00 — tomorrow.
Constraints
1≤N≤1051≤N≤105,
0≤li<ri≤1090≤li<ri≤109.
Samples
Input (stdin) | Output (stdout) |
---|---|
4 0 10 4 7 1 5 6 8 | 9 0 1 1 1 |