Under construction

Still being built. Things may change

Break, Don't Build

Time limit2sMemory limit1024 MB

Summary
Given a 2-regular geometric graph on n points, remove one incident edge per point so that the remaining edges form a non-crossing set, or report NO.
Level

Hard8 of 10

Topics
Graph, Geometry, Divide and conquer
Solved
No attempts yet

Problem

Everyone has left the house, so Alf has nothing to do. Then he noticed a map of Los Angeles on the wall and decided to study it. Alf is most interested in the roads, since there were none on his home planet Melmac. Cars there have been flying for ages.

The road system of Los Angeles is a set of nn points in general position on a plane. Pairs of points are joined by segments, which are two-way roads. Exactly two segments leave each point. Alf found this surprising.

Alf copied the road system onto a sheet of paper and decided to remove some roads, because he loves breaking things. He does not want to remove just any roads. He wants to remove exactly one road from each point so that no two remaining roads intersect. Two roads intersect if they share a common point other than their endpoints.

Alf is very curious. Help him find out whether he can do what he wants.

Input

The first line contains an integer nn (3≤n≤5003 \le n \le 500), the number of points. Each of the next nn lines contains two integers xi,yix_i, y_i (∣xi∣,∣yi∣≤109|x_i|, |y_i| \le 10^9), the coordinates of the ii-th point.

The next nn lines follow. Line ii contains two integers v,uv, u (1≤v,u≤n1 \le v, u \le n, v≠uv \ne u), the numbers of the points connected to point ii by segments.

No two points coincide, and no three points lie on one line. All segments have nonzero length.

Output

If it is impossible to remove exactly one segment from each point under these conditions, print NO. Otherwise, print YES on the first line. Then print nn lines, where line ii contains xx (1≤x≤21 \le x \le 2), the number of the segment to remove at point ii. The segment leading to point vv has number 1, and the segment leading to point uu has number 2.

Examples1

  1. Example 1

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