Assigning Fares
문제
Mayor of city M. decided to launch several new metro lines during 2020. Since the city has a very limited budget, it was decided not to dig new tunnels but to use the existing underground network.
The tunnel system of the city M. consists of metro stations. The stations are connected with bidirectional tunnels. Between every two stations and there is exactly one simple path. Each metro line the mayor wants to create is a simple path between stations and . Metro lines can intersects freely, that is, they can share common stations or even common tunnels. However, it’s not yet decided which of two directions each line will go. More precisely, between the stations and the trains will go either from to , or from to , but not simultaneously.
The city M uses complicated faring rules. Each station is assigned with a positive integer — the fare zone of the station. The cost of travel from to is defined as c_u − c_v roubles. Of course, such travel only allowed in case there is a metro line, the trains on which go from to . Mayor doesn’t want to have any travels with a negative cost, so it was decided to assign directions of metro lines and station fare zones in such a way, that fare zones are strictly increasing during any travel on any metro line.
Mayor wants firstly assign each station a fare zone and then choose a lines direction, such that all fare zones are increasing along any line. In connection with the approaching celebration of the day of the city, the mayor wants to assign fare zones so that the maximum will be as low as possible. Please help mayor to design a new assignment or determine if it’s impossible to do. Please note that you only need to assign the fare zones optimally, you don’t need to print lines’ directions. This way, you solution will be considered correct if there will be a way to assign directions of every metro line, so that the fare zones will be strictly increasing along any movement of the trains.
Please note, that in some groups it’s not required to minimize the answer, you only need to determine whether it’s possible to assign fare zones in a valid way.
입력
The first line contains an integers , , (2 ≤ n ≤ 500\, 000, 1 ≤ m ≤ 500\, 000, 0 ≤ t ≤ 1) — the number of stations in the city, the number of metro lines, and the parameter . In case you don’t have to minimize the answer. In case you should find an answer with the largest fare zone being the smallest possible.
Each of the following lines describes another metro tunnel. Each tunnel is described with integers , (1 ≤ v_i , u_i ≤ n, ). It’s guaranteed, that there is exactly one simple path between any two stations.
Each of the following lines describes another metro line. Each line is described with integers , (1 ≤ a_i , b_i ≤ n, ).
출력
In the first line print integer — the maximum fare zone used. In case parameter t is , you don’t have to minimize . In case , the should be the smallest possible.
In the next line print integers , , , (1 ≤ c_i ≤ k) — stations’ fare zones.
In case there are several possible answers, print any of them. In case it’s impossible to assign fare zones, print “-1”.
힌트
In the first example, line goes through the stations , , in this order. In this order the fare zones of the stations are increasing. Since this line has stations, at least three fare zones are needed. So the answer , , is optimal.
In the second example, it’s impossible to assign fare zones to be consistent with a metro lines.
예제
예제 1
3 1 1 1 2 2 3 1 3
3 1 2 3
예제 2
4 3 0 1 2 1 3 1 4 2 3 2 4 3 4
-1