Tiling Verification

No attempts yetTime limit1sMemory limit128 MB

Problem

You want to cover a rectangular floor completely with rectangular tiles. Given several floors, write a program that, for each floor, checks whether the tiles placed on it satisfy all three of the following conditions:

  1. The tiles are pairwise disjoint (they do not overlap).
  2. No tile extends outside the floor.
  3. The tiles cover the entire floor.

All coordinates are integers, and every tile has positive area. The lower-left corner of the floor is the origin (0,0)(0, 0), and its upper-right corner is (length,width)(\text{length}, \text{width}). Each tile is the rectangle whose lower-left corner is (xl,yl)(xl, yl) and whose upper-right corner is (xh,yh)(xh, yh).

Input

The first line contains the number of floors.

Each floor is described over several lines. The first line contains two positive integers, the length and width of the floor in millimeters; each of the length and width is at most 4000040000. The next line contains the number of tiles tt (1t1001 \le t \le 100). Each of the following tt lines describes one tile as four integers

xl yl xh yh

where (xl,yl)(xl, yl) is the lower-left corner and (xh,yh)(xh, yh) is the upper-right corner of the tile. The coordinate axes of the floor and the tiles coincide.

Output

For each floor, print exactly one of the following words on its own line:

  • NONDISJOINT: if some tiles overlap;
  • NONCONTAINED: if no tiles overlap, but some tile extends outside the floor;
  • NONCOVERING: if no tiles overlap and no tile extends outside the floor, but some part of the floor is left uncovered;
  • OK: if none of the above holds.