Problem: Koala Land consists of m bidirectional roads connecting n cities. The roads are numbered from 1 to m by order in input. It is guaranteed, that one can reach any city from every other city.

Koala starts traveling from city 1. Whenever he travels on a road, he writes its number down in his notebook. He doesn't put spaces between the numbers, so they all get concatenated into a single number.

Before embarking on his trip, Koala is curious about the resulting number for all possible destinations. For each possible destination, what is the smallest number he could have written for it?

Since these numbers may be quite large, print their remainders modulo 10^9+7. Please note, that you need to compute the remainder of the minimum possible number, not the minimum possible remainder.

Input

The first line contains two integers n and m (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^5), the number of cities and the number of roads, respectively.

The i-th of the following m lines contains integers x_i and y_i (1 ≤ x_i, y_i ≤ n, x_i ≠ y_i), representing a bidirectional road between cities x_i and y_i.

It is guaranteed, that for any pair of cities there is at most one road connecting them, and that one can reach any city from every other city. 

Output

Print n - 1 integers, the answer for every city except for the first city.

The i-th integer should be equal to the smallest number he could have written for destination i+1. Since this number may be large, output its remainder modulo 10^9+7.

Examples

Input


11 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11


Output


1
12
123
1234
12345
123456
1234567
12345678
123456789
345678826


Input


12 19
1 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 11
11 12
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10


Output


1
12
13
14
15
16
17
18
19
1210
121011


Input


12 14
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
1 3
1 4
1 10


Output


1
12
13
134
1345
13456
1498
149
14
1410
141011

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <long long mod>
struct modular {
  long long value;
  modular(long long x = 0) {
    value = x % mod;
    if (value < 0) value += mod;
  }
  modular& operator+=(modular other) {
    if ((value += other.value) >= mod) value -= mod;
    return *this;
  }
  modular& operator-=(modular other) {
    if ((value -= other.value) < 0) value += mod;
    return *this;
  }
  modular& operator*=(modular other) {
    value = value * other.value % mod;
    return *this;
  }
  modular& operator/=(modular other) {
    long long a = 0, b = 1, c = other.value, m = mod;
    while (c != 0) {
      long long t = m / c;
      m -= t * c;
      swap(c, m);
      a -= t * b;
      swap(a, b);
    }
    a %= mod;
    if (a < 0) a += mod;
    value = value * a % mod;
    return *this;
  }
  modular operator-() { return modular(-value); }
  modular operator+(modular rhs) { return modular(*this) += rhs; }
  modular operator-(modular rhs) { return modular(*this) -= rhs; }
  modular operator*(modular rhs) { return modular(*this) *= rhs; }
  modular operator/(modular rhs) { return modular(*this) /= rhs; }
  bool operator==(modular rhs) { return value == rhs.value; }
  bool operator!=(modular rhs) { return value != rhs.value; }
  bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
  return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
  x.value %= mod;
  if (x.value < 0) x.value += mod;
  return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
  stream >> x.value;
  x.value %= mod;
  if (x.value < 0) x.value += mod;
  return stream;
};
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;
inline mint pw(mint a, long long n) {
  mint res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
    }
    a *= a;
    n >>= 1;
  }
  return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
  fact.resize(n, 1);
  finv.resize(n, 1);
  for (int i = 2; i < n; i++) {
    fact[i] = fact[i - 1] * i;
  }
  finv[n - 1] /= fact[n - 1];
  for (int i = n - 2; i >= 2; i--) {
    finv[i] = finv[i + 1] * (i + 1);
  }
}
inline mint C(int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fact[n] * finv[k] * finv[n - k];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].emplace_back(i);
    g[y].emplace_back(i);
    edges[i] = {x, y};
  }
  vector<int> d(n, 1e9);
  d[0] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.emplace(d[0], 0);
  while (!pq.empty()) {
    int v = pq.top().second;
    if (pq.top().first != d[v]) {
      pq.pop();
      continue;
    }
    pq.pop();
    for (int id : g[v]) {
      int to = v ^ edges[id].first ^ edges[id].second;
      int cost = 0;
      int tmp = id + 1;
      while (tmp) {
        cost++;
        tmp /= 10;
      }
      if (d[v] + cost < d[to]) {
        d[to] = d[v] + cost;
        pq.emplace(d[to], to);
      }
    }
  }
  vector<vector<int>> ng(n);
  vector<pair<int, int>> nedges;
  vector<int> cost;
  for (int i = 0; i < m; i++) {
    int x, y;
    tie(x, y) = edges[i];
    if (d[x] > d[y]) {
      swap(x, y);
    }
    int c = 0;
    int tmp = i + 1;
    while (tmp) {
      c++;
      tmp /= 10;
    }
    if (d[y] - d[x] != c) {
      continue;
    }
    string s = to_string(i + 1);
    int from = x;
    int to = ng.size();
    for (int j = 0; j < s.size(); j++) {
      if (j == s.size() - 1) {
        to = y;
      } else {
        ng.emplace_back();
      }
      ng[from].emplace_back(nedges.size());
      nedges.emplace_back(from, to);
      cost.emplace_back(s[j] - '0');
      from = to;
      to++;
    }
  }
  swap(g, ng);
  swap(edges, nedges);
  ;
  m = g.size();
  vector<mint> ans(m);
  vector<bool> was(m);
  function<void(vector<int>, mint)> dfs = [&](vector<int> vs, mint val) {
    for (int i : vs) {
      ans[i] = val;
    }
    mint tmp = val;
    vector<vector<int>> nxt(10);
    for (int c = 0; c < 10; c++) {
      for (int v : vs) {
        for (int id : g[v]) {
          int to = edges[id].second;
          if (!was[to] && cost[id] == c) {
            was[to] = true;
            nxt[c].emplace_back(to);
          }
        }
      }
    }
    for (int i = 0; i < 10; i++) {
      if (nxt[i].empty()) {
        continue;
      }
      dfs(nxt[i], val * 10 + i);
    }
  };
  was[0] = true;
  dfs(vector<int>(1, 0), 0);
  for (int i = 1; i < n; i++) {
    cout << ans[i] << '\n';
  };
  return 0;
}