Slide Parade

아직 제출이 없습니다메모리 제한1024 MB

문제

Gooli is a huge company that owns B\mathbf{B} buildings in a hilly area, numbered 11 through B\mathbf{B}. Six years ago, Gooli built slides that allowed employees to go from one building to another. Each slide allows anyone to go from the slide's origin building to the slide's destination building, but not the other way around. Gooli's CEO is very proud of their slides and wants to organize a parade through the slides. She has tasked Melek, Gooli's Head of Transportation and a problem-solving enthusiast, with designing the parade's route.

She has some requirements for the parade route in mind:

  • It must start and end at building 11, where her office is located.
  • It must visit each building the same number of times. Being in building 11 at the start of the route does not count as a visit.
  • It must use each slide at least once.
  • It must have at most 10610^6 steps.

Given the layout of buildings and slides, help Melek find a route that satisfies all of the CEO's requirements, if one exists.

입력

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow. Each test case starts with a line containing two integers B\mathbf{B} and S\mathbf{S}: the number of buildings and slides, respectively. Then, S\mathbf{S} lines follow. The ii⁠-⁠th of these lines contains two integers U_i\mathbf{U\_i} and V_i\mathbf{V\_i}, indicating that the ii⁠-⁠th slide goes from building U_i\mathbf{U\_i} to building V_i\mathbf{V\_i}.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1). If there is no route that fulfills all the requirements, yy must be IMPOSSIBLE. If there is, yy must be an integer between S+1\mathbf{S}+1 and 106+110^6+1, inclusive, representing the length of one such route you want to exhibit. In that case, output another line containing yy integers z_1 z_2  z_yz\_1\ z\_2\ \dots\ z\_y, where z_jz\_j is the jj⁠-⁠th building in your proposed route. Notice that z_1=z_y=1z\_1 = z\_y = 1 and that each building must appear the same number of times among the z_jz\_j, except for building 11, which appears exactly one extra time.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 1U_iB1 \le \mathbf{U\_i} \le \mathbf{B}, for all ii.
  • 1V_iB1 \le \mathbf{V\_i} \le \mathbf{B}, for all ii.
  • U_iV_i\mathbf{U\_i} \ne \mathbf{V\_i}, for all ii.
  • (U_i,V_i)(U_j,V_j)(\mathbf{U\_i}, \mathbf{V\_i}) \neq (\mathbf{U\_j}, \mathbf{V\_j}), for all iji \neq j.

힌트

In Sample Case #1, another acceptable parade route is one that goes from building 11 to building 22 and then back for a total of 22 steps.

In Sample Case #2, there are no slides leading to building 11, so no valid parade can exist.

In Sample Case #3, the parade route the sample output exhibits goes through each building twice.

Sample Case #4 is pictured below.

Sample Case #5 is the one illustrated in the problem statement. In the parade route in the sample output, the slides from 22 to 33 and from 44 to 11 are used twice, but the rest of the slides are used only once each.