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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.BitSet;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private final int Inf = 0x3f3f3f3f;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            Edge[] edges = new Edge[m];

            for (int i = 0; i < m; ++i) {
                int from = in.nextInt() - 1, to = in.nextInt() - 1, need = in.nextInt();
                edges[i] = new Edge(from, to, need);
            }
            Arrays.sort(edges);

            BitSet accessible = new BitSet(n);
            accessible.set(0);
            int time = 0;

            boolean[][] graph = new boolean[n][n];

            for (int i = 0; i < m; ++i) {
                int need = edges[i].need;
                int diff = need - time;

                accessible = getaccessible(accessible, graph, diff);
                time = need;
                graph[edges[i].from][edges[i].to] = true;

                int[] dist = bfs(graph, accessible);
                if (dist[n - 1] < Inf) {
                    out.println(dist[n - 1] + time);
                    return;
                }
            }

            out.println("Impossible");
        }

        private BitSet getaccessible(BitSet accessible, boolean[][] graph, int steps) {
            int n = graph.length;
            BitSet[] ans = new BitSet[n], edges = new BitSet[n];

            for (int i = 0; i < n; ++i) {
                ans[i] = new BitSet();
                edges[i] = new BitSet();
                ans[i].set(i);
                for (int j = 0; j < n; ++j)
                    if (graph[i][j])
                        edges[i].set(j);
            }

            for (; steps > 0; steps >>= 1) {
                if ((steps & 1) != 0) ans = mul(ans, edges);
                edges = mul(edges, edges);
            }

            BitSet result = new BitSet();
            for (int i = 0; i < n; ++i)
                if (accessible.get(i))
                    result.or(ans[i]);

            return result;
        }

        private BitSet[] mul(BitSet[] A, BitSet[] B) {
            BitSet[] C = new BitSet[A.length];
            for (int i = 0; i < A.length; ++i) {
                C[i] = new BitSet();
                for (int j = 0; j < A.length; ++j)
                    if (A[i].get(j))
                        C[i].or(B[j]);
            }
            return C;
        }

        private int[] bfs(boolean[][] graph, BitSet sources) {
            int n = graph.length;
            int[] dist = new int[n];
            Arrays.fill(dist, Inf);

            Queue<Integer> Q = new ArrayDeque<>();
            for (int i = 0; i < n; ++i)
                if (sources.get(i)) {
                    Q.add(i);
                    dist[i] = 0;
                }

            while (!Q.isEmpty()) {
                int node = Q.poll();

                for (int i = 0; i < n; ++i)
                    if (graph[node][i] && dist[i] > dist[node] + 1) {
                        dist[i] = dist[node] + 1;
                        Q.add(i);
                    }
            }

            return dist;
        }

        private class Edge implements Comparable<Edge> {
            int from;
            int to;
            int need;

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

            public int compareTo(Edge other) {
                return Integer.compare(need, other.need);
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

