This page is still under construction.

Parts of this page are still being built. What you see may change.

Game

Time limit1sMemory limit512 MB

Summary
Given the pair query order, the program prints the smallest 0/1 answer string that keeps connectivity undecided until the last query.
Level

Hard8 of 10

Topics
Graph, Greedy, Game theory
Solved
No attempts yet

Problem

Jian-Jia is a boy who loves games. When someone asks him a question, he would rather turn it into a game than answer right away. Jian-Jia told his friend Mei-Yu about the flight network of Taiwan. There are nn cities, numbered 00 through n−1n-1. Some pairs of cities are joined by a direct flight, and a flight can be taken in both directions.

Mei-Yu wanted to know whether she can travel between any two cities by plane, either directly or with stopovers. Instead of telling her, Jian-Jia proposed a game. Mei-Yu asks questions of the form "are city xx and city yy joined by a direct flight?", and Jian-Jia answers yes or no immediately. Mei-Yu asks about every pair of cities exactly once, so there are r=n(n−1)/2r = n(n-1)/2 questions in total.

Mei-Yu wins if there is some i<ri < r such that the first ii answers already settle whether travel between every pair of cities is possible. If she instead needs all rr answers, Jian-Jia wins.

To make the game more fun, the two agreed that Jian-Jia may forget the real flight network. He invents it as the questions arrive, and the only thing he must respect is his own earlier answers. A flight network agrees with the first ii answers when every pair answered yes is joined by a direct flight and every pair answered no is not. A pair that has not been asked yet may be joined or not. As long as two networks agree with the first ii answers, one of them connecting all cities and the other one not, Mei-Yu has settled nothing.

You are given the order in which Mei-Yu asks. Find the lexicographically smallest sequence of answers with which Jian-Jia wins, writing no as 00 and yes as 11, where 00 comes before 11. For n≥2n \ge 2 a winning sequence always exists.

Input

The first line contains the number of cities nn.

Each of the next r=n(n−1)/2r = n(n-1)/2 lines contains one question, in the order Mei-Yu asks. A line holds two different integers xx and yy separated by a space, which is the question of whether city xx and city yy are joined by a direct flight. Ignoring the order inside a pair, every pair (x,y)(x, y) appears exactly once in the input.

Output

Print one line with a string of length rr. Its ii-th character is Jian-Jia's answer to the ii-th question, written as 00 for no and 11 for yes. If several strings let Jian-Jia win, print the lexicographically smallest one.

Constraints

  • 2≤n≤1002 \le n \le 100
  • 0≤x<n0 \le x < n, 0≤y<n0 \le y < n, x≠yx \ne y

Examples4

  1. Example 1

    Input
    2
    0 1
    
    Expected output
    0
    
  2. Example 2

    Input
    3
    0 1
    0 2
    1 2
    
    Expected output
    010
    
  3. Example 3

    Input
    4
    0 1
    0 2
    0 3
    1 2
    1 3
    2 3
    
    Expected output
    001010
    
  4. Example 4

    Input
    4
    1 2
    0 3
    0 1
    2 3
    1 3
    0 2
    
    Expected output
    000110