#K90997. Treasure Collection

    ID: 37876 Type: Default 1000ms 256MiB

Treasure Collection

Treasure Collection

Mark and his friends are on a mission to collect treasures scattered in a 2D plane. Each treasure is located at a coordinate \((x,y)\) and can be collected by moving exactly \(x\) steps right and \(y\) steps up. Starting from the origin \((0,0)\), they can only move in these two directions.

To determine whether it is possible to collect all the treasures, note that the path must be monotonic in both the horizontal and vertical directions. In particular, if you sort the treasures by their coordinates, it must hold that for every adjacent pair \((x_i,y_i)\) and \((x_{i+1},y_{i+1})\), we have \(x_i \le x_{i+1}\) and \(y_i \le y_{i+1}\). If this condition is satisfied, then collecting all treasures is possible; otherwise, it is not.

inputFormat

The first line contains an integer (t) representing the number of test cases. Each test case is described in one line: the first integer (n) denotes the number of treasures, followed by (2n) integers representing the (x) and (y) coordinates of each treasure.

outputFormat

For each test case, output a single line containing either "Possible" if it is feasible to collect all the treasures, or "Not possible" otherwise.## sample

1
2 1 1 2 3
Possible