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;
namespace ProjectMatty {
struct mat {
  vector<vector<bool> > m;
  vector<bool> &operator[](int x) { return m[x]; }
  const vector<bool> &operator[](int x) const { return m[x]; }
  int size() const { return m.size(); }
  void resize(int x) {
    m.resize(x);
    for (int i = 0; i < x; i++) m[i].resize(x);
  }
  void clear() { m.clear(); }
  void init() {
    for (int i = 0; i < m.size(); i++)
      for (int j = 0; j < m.size(); j++) m[i][j] = 0;
    for (int i = 0; i < m.size(); i++) m[i][i] = 1;
  }
};
mat operator*(mat a, mat b) {
  mat res;
  res.resize(a.size());
  bitset<201> b1[201], b2[201];
  int n = a.size() - 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) b1[i][j] = a[i][j], b2[j][i] = b[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) res[i][j] = (b1[i] & b2[j]).any();
  return res;
}
void operator*=(mat &a, mat b) { a = a * b; }
mat Pow(mat a, int y) {
  mat res, base;
  res.resize(a.size());
  res.init();
  base = a;
  while (y) {
    if (y & 1) res *= base;
    y >>= 1;
    base *= base;
  }
  return res;
}
}  // namespace ProjectMatty
using namespace ProjectMatty;
bool mp[201][201][201];
int u[201], v[201], tmp[201];
int w[201];
vector<int> rem;
signed main() {
  int n, m, c;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u[i], &v[i], &tmp[i]);
    rem.push_back(tmp[i]);
  }
  sort(rem.begin(), rem.end());
  rem.erase(unique(rem.begin(), rem.end()), rem.end());
  for (int i = 1; i <= m; i++) {
    int at = lower_bound(rem.begin(), rem.end(), tmp[i]) - rem.begin() + 1;
    mp[at][u[i]][v[i]] = 1;
  }
  for (int i = 1; i <= rem.size(); i++) w[i] = rem[i - 1];
  c = rem.size();
  mat now, g;
  now.resize(n + 1);
  g.resize(n + 1);
  now[1][1] = 1;
  g[n][n] = 1;
  for (int t = 0; t <= c; t++) {
    int e = (t == c) ? n : w[t + 1] - w[t];
    mat cur = now * Pow(g, e);
    if (cur[1][n]) {
      for (int i = 1; i <= n; i++) {
        now = now * g;
        if (now[1][n]) {
          printf("%d", i + w[t]);
          return 0;
        }
      }
    }
    now = cur;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) g[i][j] = g[i][j] | mp[t + 1][i][j];
  }
  printf("Impossible");
  return 0;
}
