Baltic Olympiad in Informatics: 2020 Day 1, Problem 3
Joker returns to Gotham City to execute another evil plan. In Gotham City, there are street junctions (numbered from
to
) and
streets (numbered from
to
). Each street connects two distinct junctions, and two junctions are connected by at most one street.
For his evil plan, Joker needs to use an odd number of streets that together form a cycle. That is, for a junction and an even positive integer
, there is a sequence of junctions
such that there are streets connecting (a)
and
, (b)
and
, and (c)
and
for each
.
However, the police are controlling the streets of Gotham City. On each day , they monitor a different subset of all streets with consecutive numbers
:
. These monitored streets cannot be a part of Joker's plan, of course. Unfortunately for the police, Joker has spies within the Gotham City Police Department; they tell him which streets are monitored on which day. Now Joker wants to find out, for some given number of days, whether he can execute his evil plan. On such a day there must be a cycle of streets, consisting of an odd number of streets which are not monitored on that day.
Input Specification
The first line of the input contains three integers ,
, and
: the number of junctions, the number of streets, and the number of days to be investigated. The following
lines describe the streets. The
-th of these lines
contains two junction numbers
and
, saying that street
connects these two junctions. It is guaranteed that any two junctions are connected by at most one street. The following
lines contain two integers
and
, saying that all streets
with
are checked by the police on day
.
Output Specification
Your output is to contain lines. Line
contains
YES
if Joker can execute his plan on day , or
NO
otherwise.
Scoring
Subtasks:
- (
points)
- (
points)
- (
points)
for
- (
points)
for
- (
points)
- (
points) No further constraints
Sample Input
6 8 2
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
4 8
4 7
Sample Output
NO
YES
Explanation for Sample Output
The graph in the example test:
Comments