atcoder#ARC143D. [ARC143D] Bridges

[ARC143D] Bridges

Score : 700700 points

Problem Statement

We have two sequences A1,,AMA_1,\ldots, A_M and B1,,BMB_1,\ldots,B_M consisting of intgers between 11 and NN (inclusive).

For a string of length MM consisting of 0 and 1, consider the following undirected graph with 2N2N vertices and (M+N)(M+N) edges corresponding to that string.

  • If the ii-th character of the string is 0, the ii-th edge connects Vertex AiA_i and Vertex (Bi+N)(B_i+N).
  • If the ii-th character of the string is 1, the ii-th edge connects Vertex BiB_i and Vertex (Ai+N)(A_i+N).
  • The (j+M)(j+M)-th edge connects Vertex jj and Vertex (j+N)(j+N).

Here, ii and jj are integers such that 1iM1 \leq i \leq M and 1jN1 \leq j \leq N, and the vertices are numbered 11 to 2N2N.

Find one string of length MM consisting of 0 and 1 such that the corresponding undirected graph has the minimum number of bridges.

Notes on bridges

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1M2×1051 \leq M \leq 2 \times 10^5
  • 1Ai,BiN1 \leq A_i, B_i \leq N

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \cdots AMA_M

B1B_1 B2B_2 \cdots BMB_M

Output

Print one string that satisfies the requirement. If there are multiple such strings, you may print any of them.

2 2
1 1
2 2
01

The graph corresponding to 01 has no bridges.

In the graph corresponding to 00, the edge connecting Vertex 11 and Vertex 33 and the edge connecting Vertex 22 and Vertex 44 are bridges, so 00 does not satisfy the requirement.

6 7
1 1 2 3 4 4 5
2 3 3 4 5 6 6
0100010