In the country there are exactly n cities numbered with positive integers from 1 to n. In each city there is an airport is located.

Also, there is the only one airline, which makes m flights. Unfortunately, to use them, you need to be a regular customer of this company, namely, you have the opportunity to enjoy flight i from city ai to city bi only if you have already made at least di flights before that.

Please note that flight i flies exactly from city ai to city bi. It can not be used to fly from city bi to city ai. An interesting fact is that there may possibly be recreational flights with a beautiful view of the sky, which begin and end in the same city.

You need to get from city 1 to city n. Unfortunately, you've never traveled by plane before. What minimum number of flights you have to perform in order to get to city n?

Note that the same flight can be used multiple times.

Input

The first line contains two integers, n and m (2 ≤ n ≤ 150, 1 ≤ m ≤ 150) — the number of cities in the country and the number of flights the company provides.

Next m lines contain numbers ai, bi, di (1 ≤ ai, bi ≤ n, 0 ≤ di ≤ 109), representing flight number i from city ai to city bi, accessible to only the clients who have made at least di flights. 

Output

Print "Impossible" (without the quotes), if it is impossible to get from city 1 to city n using the airways.

But if there is at least one way, print a single integer — the minimum number of flights you need to make to get to the destination point.

Examples

Input

3 2
1 2 0
2 3 1


Output

2


Input

2 1
1 2 100500


Output

Impossible


Input

3 3
2 1 0
2 3 6
1 2 0


Output

8
import java.io.*;
import java.util.*;
import java.math.*;
import javax.swing.text.AbstractDocument.LeafElement;

public class D implements Runnable {
	private static BufferedReader in;
	private static PrintWriter out;
	private static StringTokenizer st;
	private static Random rnd;

	static class Matrix {
		private final int size;
		private long[][] values;

		public Matrix(int size) {
			this.size = size;
			this.values = new long[size][(size / 64) + 1];
		}

		public void set(int i, int j) {
			int a = j >> 6;
			int b = (j & 63);
			values[i][a] |= (1L << b);
		}

		public boolean checkBit(int i, int j) {
			int a = j >> 6;
			int b = (j & 63);
			return ((values[i][a] >> b) & 1) != 0;
		}

		static Matrix multiply(Matrix a, Matrix b) {
			if (a.size != b.size)
				throw new AssertionError();
			int n = a.size;
			;
			Matrix c = new Matrix(n);
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < n; k++) {
					if (a.checkBit(i, k)) {
						for (int j = 0; j < b.values[k].length; j++) {
							c.values[i][j] |= b.values[k][j];
						}
					}
				}
			}
			return c;
		}

		static Matrix pow(Matrix m, long p) {
			if (p == 0) {
				Matrix res = new Matrix(m.size);
				for (int i = 0; i < m.size; i++)
					res.set(i, i);
				return res;
			} else if (p == 1) {
				return m;
			} else if (p % 2 == 0) {
				Matrix t = pow(m, p / 2);
				return Matrix.multiply(t, t);
			} else {
				Matrix t = pow(m, p - 1);
				return Matrix.multiply(t, m);
			}
		}
	}

	static class Edge implements Comparable<Edge> {
		int from, to, length;

		public Edge(int from, int to, int length) {
			this.from = from;
			this.to = to;
			this.length = length;
		}

		@Override
		public int compareTo(Edge other) {
			return Integer.compare(length, other.length);
		}
	}

	static final long INF = Long.MAX_VALUE / 128;

	private void solve() throws IOException {
		int verticesCount = nextInt(), edgesCount = nextInt();
		Edge[] edges = new Edge[edgesCount];
		for (int i = 0; i < edgesCount; i++) {
			edges[i] = new Edge(nextInt() - 1, nextInt() - 1, nextInt());
		}
		Arrays.sort(edges);
		boolean[] canReach = new boolean[verticesCount];
		canReach[0] = true;
		Matrix takenEdges = new Matrix(verticesCount);
		long before = 0;
		long result = INF;
		int cursor = 0;
		while (cursor < edgesCount) {
			long length = edges[cursor].length;
			long diff = length - before;
			before = length;
			canReach = multiply(Matrix.pow(takenEdges, diff), canReach);
			while (cursor < edgesCount && edges[cursor].length == length) {
				Edge e = edges[cursor++];
				takenEdges.set(e.from, e.to);
			}
			long currentResult = length
					+ distance(verticesCount, edges, takenEdges, canReach);
			result = Math.min(result, currentResult);
		}
		out.println(result < INF ? result : "Impossible");
	}

	private boolean[] multiply(Matrix m, boolean[] v) {
		int n = m.size;
		boolean[] result = new boolean[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (v[i] && m.checkBit(i, j)) {
					result[j] = true;
				}
			}
		}
		return result;
	}

	private long distance(int verticesCount, Edge[] edges, Matrix canEdge,
			boolean[] canReach) {
		long[] distances = new long[verticesCount];
		Arrays.fill(distances, INF);
		distances[verticesCount - 1] = 0;
		for (int it = 0; it < verticesCount; it++) {
			for (Edge e : edges) {
				if (canEdge.checkBit(e.from, e.to)) {
					distances[e.from] = Math.min(distances[e.from],
							distances[e.to] + 1);
				}
			}
		}
		long result = INF;
		for (int i = 0; i < verticesCount; i++) {
			if (canReach[i]) {
				result = Math.min(result, distances[i]);
			}
		}
		return result;
	}

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

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}