CSES - Aalto Competitive Programming 2024 - wk7 - Mon - Snakeless path
  • Time limit: 2.00 s
  • Memory limit: 512 MB

Uolevi is going for a run in the forest. There are nn landmarks in the forest numbered 1,2,,n1,2,\dots,n and there is a bidirectional path between every pair of landmarks. Uolevi starts at landmark 11 and wants to visit his favorite landmark nn. However, in the past he has run into snakes mm times. The ii-th snake appeared on a path between locations aia_i and bib_i. Uolevi is scared of snakes so he will not use these paths. Help Uolevi find a snakeless route to landmark nn or report that no such route exists. If there are multiple answers, print any.

Input

The first line contains two integers nn and mm. The ii-th of next mm lines contains two integers aia_i and bib_i.

Output

In the first line, print the number of landmarks Uolevi visits on his path to nn or 00 if there is no such path. If there exists a path then print the landmarks on the path to nn in the order Uolevi visits them on the second line separated with space as below:

ans1  ans2    anskans_1\,\,ans_2\,\,\dots\,\,ans_k

If there are multiple answers, print any.

Constraints

  • 2n1052 \leq n \leq 10^5
  • 0m3×1050 \leq m \leq 3 \times 10^5
  • 1ai<bin1 \leq a_i < b_i \leq n
  • (ai,bi)(aj,bj)(a_i, b_i) \neq (a_j, b_j) if iji \neq j
  • ans1=1ans_1 = 1
  • ansk=nans_k = n

Example 1

Input:

5 5
1 2
1 3
1 5
2 5
3 5

Output:

3
1 4 5

Example 2

Input:

5 7
1 2
1 3
1 4
1 5
2 3
2 4
2 5

Output:

0