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;
int n, m;
int dis[10010];
struct M {
  bitset<210> s[210];
} Ye;
bitset<210> ans;
struct edge {
  int a, b, v;
} e[1010];
M operator*(const M &x, const M &y) {
  M now;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (x.s[i][j]) now.s[i] |= y.s[j];
  return now;
}
bitset<210> operator*(const bitset<210> &x, const M &y) {
  bitset<210> now;
  for (int i = 0; i < n; i++) now[i] = (x & y.s[i]).any();
  return now;
}
M ksm(M a, long long b) {
  M ans = a;
  b--;
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
bool cmp(edge a, edge b) { return a.v < b.v; }
int bfs() {
  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (ans[i])
      q.push(i), dis[i] = 0;
    else
      dis[i] = 0x3f3f3f3f;
  }
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (Ye.s[i][now] && dis[i] == 0x3f3f3f3f)
        dis[i] = dis[now] + 1, q.push(i);
    }
  }
  return dis[n - 1];
}
int main() {
  scanf("%d%d", &n, &m);
  ans[0] = 1;
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &e[i].a, &e[i].b, &e[i].v);
  sort(e + 1, e + m + 1, cmp);
  if (e[1].v != 0) {
    printf("Impossible");
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    Ye.s[e[i].b - 1][e[i].a - 1] = 1;
    int last = e[i].v;
    while (e[i + 1].v == last && i + 1 <= m)
      i++, Ye.s[e[i].b - 1][e[i].a - 1] = 1;
    int cnt;
    if (i < m)
      cnt = e[i + 1].v - e[i].v;
    else
      cnt = 1;
    bitset<210> ans1 = ans * ksm(Ye, cnt);
    int nowans;
    if ((nowans = bfs()) != 0x3f3f3f3f) {
      printf("%d", last + nowans);
      return 0;
    } else {
      bool f = 0;
      for (int i = 0; i < n; i++)
        if (ans1[i]) f = 1;
      if (!f) {
        printf("Impossible");
        return 0;
      }
    }
    ans = ans1;
  }
  fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, 88);
  printf("Impossible");
}
