Sightseeing Tour

No attempts yetTime limit1sMemory limit128 MB

Problem

The city council wants to run a sightseeing bus tour through the city so that tourists can see every corner of it. The tour must be planned so that every street is driven along exactly once, and the bus must start and finish at the same junction. Streets are either one-way or two-way, and the tour bus must obey these traffic rules. Determine whether such a sightseeing tour can be constructed.

Input

The first line contains a single positive integer nn, the number of test scenarios.

Each scenario begins with a line containing two positive integers mm and ss (1m2001 \le m \le 200, 1s10001 \le s \le 1000): the number of junctions and the number of streets.

Each of the next ss lines describes one street with three integers xix_i, yiy_i, and did_i (1xi,yim1 \le x_i, y_i \le m, 0di10 \le d_i \le 1), where xix_i and yiy_i are the junctions joined by the street. If di=1d_i = 1 the street is one-way (from xix_i to yiy_i); otherwise it is two-way. You may assume there is a junction from which every other junction can be reached.

Output

For each scenario, output a single line containing possible if a sightseeing tour can be constructed, or impossible otherwise.