Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems.
×

Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Shortest Path

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputIn Ancient Berland there were *n* cities and *m* two-way roads of equal length. The cities are numbered with integers from 1 to *n* inclusively. According to an ancient superstition, if a traveller visits three cities *a* _{ i}, *b* _{ i}, *c* _{ i} in row, without visiting other cities between them, a great disaster awaits him. Overall there are *k* such city triplets. Each triplet is ordered, which means that, for example, you are allowed to visit the cities in the following order: *a* _{ i}, *c* _{ i}, *b* _{ i}. Vasya wants to get from the city 1 to the city *n* and not fulfil the superstition. Find out which minimal number of roads he should take. Also you are required to find one of his possible path routes.

Input

The first line contains three integers *n*, *m*, *k* (2 ≤ *n* ≤ 3000, 1 ≤ *m* ≤ 20000, 0 ≤ *k* ≤ 10^{5}) which are the number of cities, the number of roads and the number of the forbidden triplets correspondingly.

Then follow *m* lines each containing two integers *x* _{ i}, *y* _{ i} (1 ≤ *x* _{ i}, *y* _{ i} ≤ *n*) which are the road descriptions. The road is described by the numbers of the cities it joins. No road joins a city with itself, there cannot be more than one road between a pair of cities.

Then follow *k* lines each containing three integers *a* _{ i}, *b* _{ i}, *c* _{ i} (1 ≤ *a* _{ i}, *b* _{ i}, *c* _{ i} ≤ *n*) which are the forbidden triplets. Each ordered triplet is listed mo more than one time. All three cities in each triplet are distinct.

City *n* can be unreachable from city 1 by roads.

Output

If there are no path from 1 to *n* print -1. Otherwise on the first line print the number of roads *d* along the shortest path from the city 1 to the city *n*. On the second line print *d* + 1 numbers — any of the possible shortest paths for Vasya. The path should start in the city 1 and end in the city *n*.

Examples

Input

4 4 1

1 2

2 3

3 4

1 3

1 4 3

Output

2

1 3 4

Input

3 1 0

1 2

Output

-1

Input

4 4 2

1 2

2 3

3 4

1 3

1 2 3

1 3 4

Output

4

1 3 2 3 4

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/06/2020 09:46:17 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|