Two-color coloring
Time limit2sMemory limit256 MB
Given an undirected multigraph, decide whether it is bipartite so its vertices can be colored with two colors.
Problem
Tony likes coloring books.
Tony first draws a picture using only circles and straight lines that join two circles. Not every pair of circles has a line between them. After drawing, he wants to color the circles so that two circles joined by a line get different colors.
Finding the smallest number of colors is hard, so Tony only wants to know whether two colors are enough.
You are given the numbers of the circles and the lines that join them. Decide whether the picture can be colored with two colors.
Input
The first line contains the number of test cases .
The first line of each test case contains the number of circles () and the number of lines (). Each of the next lines describes one line of the picture as , meaning that circle and circle are joined by a straight line. Circles are numbered from 1 to . The same line may be given more than once.
Output
For each test case print one line. Print possible if the picture can be colored with two colors, and impossible otherwise.