Chess Tournament

Count the equal two-team splits in which every pair across the teams played at least once, and print the lexicographically smallest team containing player 1.

Medium7GraphUnion-findDynamic programmingNo attempts yetTime limit3sMemory limit256 MB

Problem

A big chess tournament is being held in your town, so you go and watch. Two teams A and B, each with nn players, face each other, and every player of team A plays one game against every player of team B. The team with more wins takes the title. In a drawn game each player gets 1/21/2 point.

You do not know which players are on which team, but you wrote down every game played during the tournament. The catch is that some players also played outside the schedule, for practice or for fun. Some of those games were against a teammate, some against an opponent they had already faced. Can you still tell who belongs to which team?

Count the team assignments that agree with your list, that is, the assignments in which every pair of players from opposite teams appears in the list at least once. The two teams have no names, so swapping A and B gives the same assignment.

Input

The first line has the number of test cases TT (1T1001 \le T \le 100). Each test case is given as follows.

  • One line with two integers NN and MM, the number of players per team and the number of recorded games (1N2501 \le N \le 250, N2M106N^2 \le M \le 10^6).
  • Then MM lines, each with two different integers AA and BB (1A<B2N1 \le A < B \le 2N), meaning that player AA and player BB played a game.

The same pair may appear more than once. The sum of MM over all test cases is at most 10610^6. Players are numbered 1 through 2N2N, and at least one assignment that agrees with the list always exists.

Output

For each test case print two lines.

  • The first line has the number of assignments modulo 10810^8. The printed value must be at least 0 and less than 10810^8. The remainder can be 0 even though an assignment exists.
  • The second line has the NN players of the team that contains player 1, in increasing order, separated by single spaces. When several assignments are possible, print the one whose increasing sequence is lexicographically smallest.