The Swallowing Ground

Now that the wicked is punished, there is still work to do. For example, the ground needs to seal itself up. (Otherwise, good people will accidentally fall into Hell, which is not good.)

The ground swallowed Don Giovanni by collapsing: Part of the ground collapsed--fell off to Hell--and this created a gap that swallowed Don Giovanni. The only way the ground can be fixed is by sliding landmasses to close up the gap. Here is an example. The left diagram shows the ground with a ravine. Assume that the ground extends infinitely to the north and to the south, and there are seams on the east and west ends; so the northern block can slide southward, and the southern block can slide northward. The right diagram shows the gap closed.

tex2html_wrap220

Here is another example. The ravine in the left diagram cannot be closed perfectly by sliding the ground northward and southward. The right diagram shows the result of the best effort: there is still a hole.

tex2html_wrap222

Write a program to determine if the gap can be closed. The ground is a grid with rows (a row runs east-west) and columns (a column runs north-south). Holes are cells on the grid, and the gap consists of holes.

Input

The first line contains the number of columns W of the ground to be considered. Then W lines follow, specifying the boundary of the gap by columns: a line represents a column, and the order of the lines follows the east-to-west order. Each line contains tex2html_wrap_inline228, the north-most row of the gap in this column, and tex2html_wrap_inline230, the south-most row of the gap in this column. Row numbers are integers between -100 and 100 inclusive.

The input specifies a valid gap: the holes separate the ground into exactly a northern block and a southern block. There are no holes embedded inside a block. There are no islands.

Output

Output the line

yes
if the gap can be closed by sliding blocks north and south; and
no
otherwise.

Sample Input

This sample input corresponds to the first diagram.

5
2 1
1 0
1 0
0 -1
2 1

Sample Output

yes



Solution in C
Solution in Java
Test Input 0/Test Output 0
Test Input 1/Test Output 1
Test Input 2/Test Output 2
Test Input 3/Test Output 3
Test Input 4/Test Output 4
Test Input 5/Test Output 5
Test Input 6/Test Output 6