### PROBLEM LINK:

**Author:** Ilya Malinovsky

**Tester:** Shiplu Hawlader and Mahbubul Hasan

**Editorialist:** Lalit Kundu

### DIFFICULTY:

EASY-MEDIUM

### PREREQUISITES:

Ad-Hoc

### PROBLEM:

Numbers 1 to N are written in clockwise order. Given k disjoint intervals(each interval given in clockwise direction) (l_{1},r_{1}),(l_{2},r_{2})…(l_{k},r_{k}) denoting boy’s division. These intervals cover the whole set.

Similarily, given is the Chef’s division(what he wants to achieve) (a_{1},b_{1}),(a_{2},b_{2})…(a_{p},b_{p}). He can divide an interval from boy’s intervals into disjoint intervals but he cannot join two of the boy’s intervals. Check if it’s possible to acheive his intervals from boy’s intervals.

### QUICK EXPLANATION:

Answer is “Yes” iff for each interval in boy’s division, the left border coincides with left border of some interval in chef’s division.

### EXPLANATION:

For any i, if there doesn’t exist a j such that l_{i} = a_{j}, that means segments numberered (l_{i}-1) and (l_{i}) will be occuring together in chef’s division but they are in different parts in boys division. Hence, it will equivalent to chef joining to different parts of boys division which is not allowed.

If the condition that “for each interval in boy’s division, the left border coincides with left border of some interval in chef’s division” this kind of scenario will occur.

Here, red lines denote chef’s divisions. Only those divisions of chef are shown where left border coincide with boys’ divisions.

Since, chef’s divisions also cover all the parts, the remaining parts will be covered by the remaining divisions.

Therefore, we have to check only one condition. Pseudo code:

```
n,k,p=input()
flag=0
set myset
for i=0 to k:
x,y=input()
myset.insert(x)
for i=0 to p:
x,y=input()
if x not in myset: flag=1
if flag, print "No"
else, print "Yes"
```

### AUTHOR’S AND TESTER’S SOLUTIONS:

To be updated soon.