Flappy Bird

Time limit: 0.1s Memory limit: 32MB Input: Output:

After many years of obscurity, the well known mobile game Flappy Bird has finally become downloadable again and Stefan decided to install it on his mobile phone in a quest to relive his old childhood days.

In this version, we are given nn pairs of towers, which can be represented as a grid of nn lines and an infinite number of columns (unlike the original version of the game, the towers are oriented horizontally, rather than vertically). In this grid, we know for each of the nn lines the interval of positions which are accessible by our bird and we want to know whether the bird can win the game, if the player plays the game perfectly.

In order for a bird to pass a pair of towers, it has to be able to move from the current position to any position from the next pair of towers, without having to touch any walls. Furthermore, we will assume that the bird has an infinite speed (it can move instantly to any point from the next pair of free spaces, as long as this is physically possible).

Input data

The first line of the input contains nn, the number of pairs of towers.

The next nn lines of the input contain two integers each, aa and bb, representing that the free spaces are between columns aa and bb.

Output data

On the first line of the output we will print YES or NO based on whether the bird can win the game or not.

Constraints and clarifications

  • 1n1051 \leq n \leq 10^5
  • 1ab1091 \leq a \leq b \leq 10^9
  • All tests are grouped in a single group worth 100100 points.

Example 1

stdin

5
3 6
4 7
2 4
4 5
1 5

stdout

YES

Example 2

stdin

4
4 7
5 6
1 3
3 6

stdout

NO

Log in or sign up to be able to send submissions!