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 n landmarks in the forest numbered 1,2,\dots,n and there is a bidirectional path between every pair of landmarks. Uolevi starts at landmark 1 and wants to visit his favorite landmark n. However, in the past he has run into snakes m times. The i-th snake appeared on a path between locations a_i and b_i. Uolevi is scared of snakes so he will not use these paths. Help Uolevi find a snakeless route to landmark n or report that no such route exists. If there are multiple answers, print any.

Input

The first line contains two integers n and m. The i-th of next m lines contains two integers a_i and b_i.

Output

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

ans_1\,\,ans_2\,\,\dots\,\,ans_k

If there are multiple answers, print any.

Constraints

  • 2 \leq n \leq 10^5
  • 0 \leq m \leq 3 \times 10^5
  • 1 \leq a_i < b_i \leq n
  • (a_i, b_i) \neq (a_j, b_j) if i \neq j
  • ans_1 = 1
  • ans_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