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
#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 405;
long long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, dis[df],
    ans = inf, d[df];
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
struct edge {
  long long frm, to, far;
} e[df << 2];
bool cmp(edge st, edge ch) { return st.far < ch.far; }
struct node {
  bitset<df> v[df];
  node() {
    for (long long i = (1); i <= (n); ++i)
      for (long long j = (1); j <= (n); ++j) v[i][j] = 0;
  }
  void fir() {
    for (long long i = (1); i <= (n); ++i) v[i][i] = 1;
  }
  friend node operator*(node st, node ch) {
    node ret;
    for (long long i = (1); i <= (n); ++i)
      for (long long k = (1); k <= (n); ++k)
        if (st.v[i][k]) ret.v[i] |= ch.v[k];
    return ret;
  }
} a, g;
node pw(node x, long long y) {
  node ty;
  ty.fir();
  while (y) {
    if (y & 1) ty = ty * x;
    y >>= 1;
    x = x * x;
  }
  return ty;
}
void bfs() {
  for (long long i = (1); i <= (n); ++i) d[i] = inf;
  queue<long long> que;
  for (long long i = (1); i <= (n); ++i)
    if (a.v[1][i]) que.push(i), d[i] = 0;
  while (!que.empty()) {
    long long u = que.front();
    que.pop();
    for (long long i = (1); i <= (n); ++i)
      if (g.v[u][i] && d[i] == inf) d[i] = d[u] + 1, que.push(i);
  }
  return;
}
int main() {
  n = read(), m = read();
  for (long long i = (1); i <= (m); ++i)
    e[i].frm = read(), e[i].to = read(), e[i].far = read();
  sort(e + 1, e + m + 1, cmp);
  a.v[1][1] = 1;
  d[n] = inf;
  long long lst = 0;
  for (long long i = (1); i <= (m); ++i) {
    if (ans < e[i].far) break;
    long long dt = e[i].far - lst;
    lst = e[i].far;
    a = a * pw(g, dt);
    g.v[e[i].frm][e[i].to] = 1;
    if (i == m || e[i].far != e[i + 1].far) bfs();
    ans = min(ans, d[n] + lst);
  }
  if (ans == inf) return puts("Impossible"), 0;
  printf("%lld\n", ans);
}
