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;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int add(int a, int b, int m = MOD) { return (a + b) % m; }
int mul(long long a, long long b, int m = MOD) { return (a * b) % m; }
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int MAX = 1e6 + 5;
int n;
int m;
int nodes;
vector<pair<int, int> > G[MAX];
int D[MAX];
int p[MAX];
int pa[MAX];
int val[MAX];
int res[MAX];
void process(int pos, int l, int r) {
  vector<int> v;
  for (int x = pos; x > 0; x /= 10) v.emplace_back(x % 10);
  reverse((v).begin(), (v).end());
  int par = l;
  for (int i = 0; i + 1 < v.size(); i++) {
    G[par].emplace_back(make_pair(nodes, v[i]));
    par = nodes;
    nodes += 1;
  }
  G[par].emplace_back(make_pair(r, v.back()));
}
void BFS(int src) {
  for (int i = 1; i < nodes; i++) {
    D[i] = -1;
    res[i] = 0;
  }
  D[src] = 0;
  p[src] = 0;
  val[src] = 0;
  res[src] = 0;
  vector<pair<int, int> > frontier;
  vector<pair<int, int> > new_frontier;
  frontier.emplace_back(make_pair(src, 0));
  while (!frontier.empty()) {
    new_frontier.clear();
    int L = 0, R = 0;
    while (L < frontier.size()) {
      while (R < frontier.size() and frontier[L].second == frontier[R].second)
        R += 1;
      for (int d = 0; d < 10; d++) {
        for (int i = L; i < R; i++) {
          int u = frontier[i].first;
          while (!G[u].empty() and G[u].back().second == d) {
            int v = G[u].back().first;
            if (D[v] == -1) {
              p[v] = d;
              pa[v] = u;
              D[v] = D[u] + 1;
              res[v] = add(mul(10, res[u]), d);
              if (new_frontier.empty())
                val[v] = 0;
              else {
                int last = new_frontier.back().first;
                if (make_pair(val[pa[last]], p[last]) == make_pair(val[u], d)) {
                  val[v] = new_frontier.back().second;
                } else {
                  val[v] = new_frontier.back().second + 1;
                }
              }
              new_frontier.emplace_back(make_pair(v, val[v]));
            }
            G[u].pop_back();
          }
        }
      }
      L = R;
    }
    swap(frontier, new_frontier);
  }
}
int main() {
  scanf("%d %d", &(n), &(m));
  nodes = n + 1;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &(u), &(v));
    process(i, u, v);
    process(i, v, u);
  }
  for (int i = 1; i < nodes; i++) {
    sort((G[i]).begin(), (G[i]).end(), [&](pair<int, int> a, pair<int, int> b) {
      return a.second > b.second;
    });
  }
  BFS(1);
  for (int i = 2; i <= n; i++) {
    printf("%d\n", res[i]);
  }
  return 0;
}