Alternating Current

Each of M circular arcs must get a direction (clockwise or counter-clockwise) so that every segment lies in at least one arc of each direction, or report impossible.

Medium7GraphBFSImplementationGreedyNo attempts yetTime limit3sMemory limit1024 MB

Problem

Fredrik has a model railway consisting of NN segments connected in a circle. The segments are numbered 1,2,,N1, 2, \dots, N in clockwise order. Electricity is supplied through MM curved wires running along the circle, and every segment is covered by at least one wire.

Fredrik wants to install a switch on every segment. The switches need alternating current. In Fredrik's view, alternating current means current flowing in both directions. Each wire carries current in one direction only, clockwise or counter-clockwise, and Fredrik can choose the direction of every wire. The directions must be chosen so that every segment is covered by at least one wire with clockwise current and at least one wire with counter-clockwise current.

Find such a choice of directions if one exists.

The figure above shows a solution for the first sample. The curved arrows outside the railway are the wires, and each arrow direction is Fredrik's choice of current direction. Reversing every arrow gives another valid solution.

This idea makes sense because the railway is Swedish, and in Sweden every switch (in Swedish växlar) uses alternating current (in Swedish växelström).

Input

The first line contains two integers NN and MM, the number of segments and the number of wires.

Each of the next MM lines contains two integers aa and bb with 1a,bN1 \le a, b \le N. The wire covers segments a,a+1,,ba, a+1, \dots, b. If bb is smaller than aa, the interval wraps around the circle and covers segments a,,N,1,,ba, \dots, N, 1, \dots, b. If a=ba = b, the wire covers only that single segment.

Output

Output a single line with MM characters, each 00 or 1. The iith character must be 0 if the current in the iith input wire flows clockwise, and 1 if it flows counter-clockwise. If several solutions exist, output any of them.

If no valid solution exists, output impossible.