시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB32266.667%

문제

There is a railway between Zürich and Lugano of length $s$ kilometers. The railway crosses the beautiful Alps, resulting in a spectacular scenery during the ride. Since some passes are too high for the railway, there are $t$ tunnels on the track. The $i$-th of them starts $a_i$ kilometers from Zürich and ends $b_i$ kilometers from Zürich. (Thus, the length of the $i$-th tunnel is $b_i - a_i$.)

You have a timetable of the rail $m$ service between the two cities. There are services from Zürich to Lugano, the $j$-th of which departs at $c_j$ minutes, and $n$ services from Lugano to Zürich, the $k$-th of which departs at $d_k$ minutes. All trains operating on the track have a constant speed of $1$ kilometer per minute, regardless of their direction and whether they are in a tunnel or not. There are no stations on the route, and the trains never stop at semaphores. Hence, each service arrives to its destination in exactly $s$ minutes.

The length of a train is negligible in comparison to the length of the railway, so in this problem please assume that each train is a point that moves along the railway.

Usually, the railway has two tracks: one in each direction. The only exception are the tunnels. Each tunnel has just a single track that can be used in either direction.

Whenever two trains going in the opposite directions meet outside a tunnel, they can pass each other safely. This includes trains meeting exactly at either end of a tunnel. On the other hand, if a pair of trains meets strictly inside a tunnel, there is a collision.

Given the description of the tunnels and the train services, determine whether there will be any collision.

입력

The first line contains four space-separated integers $s$, $t$, $m$, $n$ ($1 \le s \le 1\,000\,000\,000$, $0 \le t \le 100\,000$, $0 \le m, n \le 2\,000$) — the length of the track, the number of tunnels, the number of services from Zürich and the number of services from Lugano, respectively.

The second line contains $t$ space-separated integers $a_i$ ($0 \le a_i < s$) — the starting positions of the tunnels.

The third line contains $t$ space-separated integers $b_i$ ($0 < b_i \le s$) — the ending positions of the tunnels.

For each $i$ between $1$ and $t$, $a_i < b_i$ holds. Additionally, for each $i$ between $1$ and $t-1$, $b_i < a_{i+1}$. (In other words, each tunnel has a positive length, the tunnels are pairwise disjoint, and they are given in increasing order of distance from Zürich.)

The fourth line contains $m$ space-separated integers $c_j$ ($0 \le c_j \le 1\,000\,000\,000$) — the starting times (in minutes) of the services starting in Zürich. The times are given in increasing order, that is, $c_j < c_{j+1}$ for all valid $j$.

The fifth line contains $n$ space-separated integers $d_k$ ($0 \le d_k \le 1\,000\,000\,000$) — the starting times (in minutes) of the services starting in Lugano. The times are given in increasing order, that is, $d_k < d_{k+1}$ for all valid $k$.

출력

Output a single line, containing "YES" (quotes for clarity) if at least one crash occurs, or "NO" if all trains reach their destination safely.

제한

In all subtasks except the last one, the value of $s$ and all $c_j$ and $d_k$ are even.

서브태스크

번호배점제한
114

$t, m, n \le 100$ and $s \le 5\,000$.

216

$t \le 5\,000$ and $s \le 1\,000\,000$.

341

There are no further restrictions.

429

There are no further restrictions. Additionally, $s$, $c_j$ and $d_k$ are not necessarily even.

예제 입력 1

100 2 1 4
20 50
30 60
120
30 100 200 250

예제 출력 1

NO

예제 입력 2

1000 1 1 1
600
700
100
400

예제 출력 2

YES

예제 입력 3

1000 1 1 1
600
700
100
300

예제 출력 3

NO

예제 입력 4

1000 1 1 1
600
700
100
500

예제 출력 4

NO

노트

In the first example there are two tunnels on a track of length $100$ kilometers: one $20$ to $30$ kilometers from Zürich, the other $50$ to $60$ kilometers from Zürich. The only train coming from Zürich manages to avoid all the Lugano services as follows:

  • the first is met $5$ kilometers from Zürich,
  • the second is met halfway between the tunnels,
  • the third is met $10$ kilometers from Lugano,
  • the fourth starts long after the Zürich train had arrived at its destination.

In the second example the only two trains meet exactly in the middle of the only tunnel, resulting in a crash.

In the third example the two trains meet exactly at the end of the tunnel that is closer to Zürich. In the fourth example they meet exactly at the other end of the tunnel. Both cases are fine, the trains pass each other and reach their destination safely.

채점 및 기타 정보

  • 예제는 채점하지 않는다.