This page is still under construction.

Parts of this page are still being built. What you see may change.

Subway Map

Time limit1sMemory limit128 MB

Summary
Decide whether every station label fits above or below the line covering its own station point and no other, with no two labels overlapping.
Level

Medium7 of 10

Topics
Backtracking, Geometry, Intervals
Solved
No attempts yet

Problem

Subway map example

You want to draw a subway map that is easy for citizens to read. A single line is an infinitely long straight line, and several stations lie on it. Each station is drawn as a single point on the line and has a unique name.

Each station name is written inside a rectangular label. All labels have the same height, and each label's width is proportional to the length of the name. A label is drawn either above or below the line so that one of its edges lies flush against the line.

A map is called a good map when it satisfies all three of the following conditions.

  1. Each station's label must touch the point that represents that station.
  2. A station's label must not pass through the point of any other station. In other words, no other station's point may lie in the interior of any edge of the label. It is fine for a point to touch the boundary of a label (a corner or the end of an edge).
  3. Two different labels may touch each other but must not overlap.

The figure below shows an example that is not a good map.

A map that is not good

Given one straight line and the stations on it, write a program that decides whether a good map exists. Each station is assumed to be a single point on the line.

Input

Input is given through standard input. The first line contains the number of test cases TT (1≤T≤201 \le T \le 20).

For each test case, the first line contains the number of stations NN (1≤N≤201 \le N \le 20). Each of the next NN lines describes one station with two integers separated by a space: the coordinate xx (0≤x≤10000 \le x \le 1000) on the line and the width rr (0<r≤10000 < r \le 1000) of that station's label. Stations are given in increasing order of the coordinate xx.

Output

For each test case, print YES if a good map exists and NO otherwise, each on its own line.

Examples1

  1. Example 1

    Input
    2
    3
    0 5
    2 4
    3 2
    5
    2 5
    3 3
    5 3
    6 2
    7 5
    
    Expected output
    NO
    YES