A digital logic circuit on a printed circuit board (PCB) is a collection of interconnected parts, usually integrated circuit (IC) chips. Each IC chip has several pins that must be connected by wires to pins on other chips or to a power line. Most PCBs are built as a stack of layers. The wiring pattern in each layer consists of horizontal and vertical wires. In a multilayer board, layers are joined by drilled holes called vias, which form conductive paths between layers.
When designing a complex PCB, one special layer is reserved for the power supply. That layer has the following properties.
To keep the design cost effective, we want to minimize the number of vertical wires attached to the power line on this layer.
A vertical wire placed at a via (s,t) runs from the power line up to that via. It therefore powers exactly the horizontal wires (p,q,r) with q≤s≤r and p<t.
In figure (a) there are four horizontal wires and seven vias. The minimum number of vertical wires needed to power every horizontal wire is three. Figure (b) shows one layout that uses three vertical wires. Note that a single horizontal wire may be crossed by more than one vertical wire.

(a)

(b)
Given the horizontal wires and the vias, compute the minimum number of vertical wires that connect the power line to all horizontal wires.
The first line contains the number of test cases T.
Each test case begins with a line containing two integers M and N (1≤M,N≤100), where M is the number of horizontal wires and N is the number of vias.
Each of the next M lines describes one horizontal wire with three integers p, q, r, where p (1≤p≤10000) is the y-coordinate of the wire and q, r (1≤q<r≤10000) are the x-coordinates of its left and right end points. No two horizontal wires intersect.
Each of the following N lines describes one via with two integers s, t (1≤s,t≤10000), which are the x- and y-coordinates of the via, respectively. At most one via lies on any vertical line, and no via lies on a horizontal wire. The power line lies on the x-axis.
For each test case, print a single line containing the minimum number of vertical wires that connect the power line to every horizontal wire. If it is impossible to connect every horizontal wire with at least one vertical wire, print IMPOSSIBLE instead.