Problem: Friends Alex and Bob live in Bertown. In this town there are n crossroads, some of them are connected by bidirectional roads of equal length. Bob lives in a house at the crossroads number 1, Alex — in a house at the crossroads number n.

One day Alex and Bob had a big quarrel, and they refused to see each other. It occurred that today Bob needs to get from his house to the crossroads n and Alex needs to get from his house to the crossroads 1. And they don't want to meet at any of the crossroads, but they can meet in the middle of the street, when passing it in opposite directions. Alex and Bob asked you, as their mutual friend, to help them with this difficult task.

Find for Alex and Bob such routes with equal number of streets that the guys can follow these routes and never appear at the same crossroads at the same time. They are allowed to meet in the middle of the street when moving toward each other (see Sample 1). Among all possible routes, select such that the number of streets in it is the least possible. Until both guys reach their destinations, none of them can stay without moving. 

The guys are moving simultaneously with equal speeds, i.e. it is possible that when one of them reaches some of the crossroads, the other one leaves it. For example, Alex can move from crossroad 1 to crossroad 2, while Bob moves from crossroad 2 to crossroad 3.

If the required routes don't exist, your program should output -1.

Input

The first line contains two integers n and m (2 ≤ n ≤ 500, 1 ≤ m ≤ 10000) — the amount of crossroads and the amount of roads. Each of the following m lines contains two integers — the numbers of crossroads connected by the road. It is guaranteed that no road connects a crossroads with itself and no two crossroads are connected by more than one road.

Output

If the required routes don't exist, output -1. Otherwise, the first line should contain integer k — the length of shortest routes (the length of the route is the amount of roads in it). The next line should contain k + 1 integers — Bob's route, i.e. the numbers of k + 1 crossroads passed by Bob. The last line should contain Alex's route in the same format. If there are several optimal solutions, output any of them.

Examples

Input

2 1
1 2


Output

1
1 2 
2 1 


Input

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


Output

-1


Input

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


Output

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

Solution (in JAVA):

Solution:
import static java.util.Arrays.deepToString;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[][] ns = new int[n+1][n+1];

		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			ns[a][++ns[a][0]] = b;
			ns[b][++ns[b][0]] = a;
		}

		int[][][] memo = new int[n][n][2];
		int[][] trA = new int[n][n];
		int[][] trB = new int[n][n];

		fill(memo, -1);

		memo[0][n-1][0] = 0;

		int[] q = new int[6 * n * n];
		int qt = 0;
		int qh = 0;
		q[qt++] = 0;
		q[qt++] = n-1;
		q[qt++] = 0;
		while (qt - qh > 0) {
			int a = q[qh++];
			int b = q[qh++];
			int turn = q[qh++];

			if (a == n-1 && b == 0 && turn == 0) break;

			int d = memo[a][b][turn];

			int nt = 1 - turn;
			if (turn == 0) {
				for (int i = 1; i <= ns[a][0]; i++) {
					int na = ns[a][i]; 
					if (memo[na][b][nt] == -1) {
						memo[na][b][nt] = d + 1;
						q[qt++] = na;
						q[qt++] = b;
						q[qt++] = nt;
						trA[na][b] = a;
					}
				}
			} else {
				for (int i = 1; i <= ns[b][0]; i++) {
					int nb = ns[b][i];
					if (nb == a) continue;
					if (memo[a][nb][nt] == -1) {
						memo[a][nb][nt] = d + 1;
						q[qt++] = a;
						q[qt++] = nb;
						q[qt++] = nt;
						trB[a][nb] = b;
					}
				}
			}
		}

		if (memo[n-1][0][0] == -1) {
			out.println(-1);
		} else {
			int len = memo[n-1][0][0] / 2;

			int a = n-1;
			int b = 0;

			int[] pathA = new int[len + 1];
			int[] pathB = new int[len + 1];
			for (int p = len; p > 0; p--) {
				pathA[p] = a + 1;
				pathB[p] = b + 1;
				b = trB[a][b];
				a = trA[a][b];
			}
			pathA[0] = 1;
			pathB[0] = n;

			out.println(pathA.length - 1);
			print(pathA);
			print(pathB);

		}


	}

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	static void fill(int[][] a, int val) {
		for(int i = 0; i < a.length; i++) Arrays.fill(a[i], val);
	}
	static void fill(int[][][] a, int val) {
		for(int i = 0; i < a.length; i++) fill(a[i], val);
	}

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}