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

문제

Despite its efforts, Indinesia is still regularly hit by uncontrolled forest fires, which causes problems to the local citizens as well as neighbouring countries. Many solutions have been proposed and executed (e.g., dropping water bombs on the burning area), but new hotspots always emerge over time. Nonetheless, Indra, the president of Indinesia, is not yet giving up in solving this problem.

Indinesia has two fire lookout towers located at (x1, y1) and (x2, y2) where x1 < x2 and y1 < y2. Moreover, there are N hotspots scattered across the country. The i-th hotspot is a circle with radius ri and centered at (fxi, fyi). A point (x, y) is considered safe if it satisfies all the following properties:

  1. x1 ≤ x ≤ x2,
  2. y1 ≤ y ≤ y2,
  3. It must not lie strictly inside any burning area; in other words, for all 1 ≤ i ≤ N, the distance of (x, y) to (fxi, fyi) should be at least ri.

The locations of the two towers are guaranteed to be safe. The two towers can communicate properly if and only if there exists a safe path connecting the two towers. A path is considered as safe if and only if all points on the path are safe. Note that "path" as defined in this problem is any continuous and unnecessarily-straight line.

Your task in this problem is to determine whether the two towers are able to communicate properly.

입력

The first line of input contains five integers: x1 y1 x2 y2 N (-1,000,000 ≤ x1 < x2 ≤ 1,000,000; -1,000,000 ≤ y1 < y2 ≤ 1,000,000; 0 ≤ N ≤ 1000) in a line denoting the location of the two towers (x1, y1) and (x2, y2) and the number of hotspots. The next N lines, each contains three integers: fxi fyi ri (-1,000,000 ≤ fxi, fyi ≤ 1,000,000; 1 ≤ ri ≤ 2,000,000) in a line denoting the location of the center of the i-th hotspot (fxi, fyi) and its radius of burning area. It is guaranteed that there are no two hotspots at the same (fxi, fyi) location. 

출력

The output contains either "YES" or "NO" (without quotes) whether the two towers can communicate properly, in a line.

예제 입력 1

-15 -10 15 10 5
-20 7 9
-2 3 6
8 -3 4
-1 -8 3
-9 -1 3

예제 출력 1

YES

예제 입력 2

2 10 18 30 3
10 20 5
10 29 5
10 11 5

예제 출력 2

NO

예제 입력 3

2 10 18 30 3
10 20 5
10 25 5
10 10 5

예제 출력 3

YES

힌트

Explanation for the 1st sample case

For the first sample, the following figure shows one of the safe path connecting the two towers.

Explanation for the 2nd sample case

For the second sample, there is no possible safe path.

Explanation for the 3rd sample case

For the third sample, the following figures show two examples of safe paths connecting the two towers. 

Notice that the points at (10, 15) in the top figure and (10, 30) in the bottom one are safe.