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;
struct dataHash {
  long long code[3];
};
const long long N = 1e6 + 4, LOG = 20, oo = 1e9 + 7;
long long MOD[3] = {(long long)1e9 + 7, (long long)1e9 + 3,
                    (long long)1e9 + 21};
long long orgN, n, m, debug;
vector<pair<long long, long long> > adj[N];
queue<long long> Q;
dataHash Hash[N];
long long d[N], Trace[N][LOG + 2], idEdge[N];
void update_Hash(dataHash &a, dataHash b, long long dig) {
  for (long long id = 0; id < (long long)3; ++id)
    a.code[id] = (b.code[id] * 10 + dig) % MOD[id];
}
long long Compare(long long u, long long v, long long last_u,
                  long long last_v) {
  long long org_u = u, org_v = v;
  for (long long i = LOG; i >= (long long)0; --i) {
    long long par_u = Trace[u][i], par_v = Trace[v][i];
    bool ok = false;
    for (long long id = 0; id < (long long)3; ++id)
      if (Hash[par_u].code[id] != Hash[par_v].code[id]) {
        ok = true;
        break;
      }
    if (ok) {
      u = par_u;
      v = par_v;
    }
  }
  if (idEdge[u] == idEdge[v]) return (last_u <= last_v) ? org_u : org_v;
  return (idEdge[u] < idEdge[v]) ? org_u : org_v;
}
void sol() {
  for (long long i = 1; i <= (long long)n; ++i) d[i] = oo;
  d[1] = 0;
  Q.push(1);
  while (Q.size()) {
    long long u = Q.front();
    Q.pop();
    for (pair<long long, long long> foo : adj[u]) {
      long long v = foo.second, dig = foo.first;
      if (d[v] > d[u] + 1) {
        d[v] = d[u] + 1;
        Q.push(v);
        Trace[v][0] = u;
        idEdge[v] = dig;
        for (long long i = 1; i <= (long long)LOG; ++i)
          Trace[v][i] = Trace[Trace[v][i - 1]][i - 1];
        update_Hash(Hash[v], Hash[u], dig);
      } else if (d[v] == d[u] + 1) {
        long long best = Compare(Trace[v][0], u, idEdge[v], dig);
        if (best != u) continue;
        Trace[v][0] = best;
        idEdge[v] = dig;
        for (long long i = 1; i <= (long long)LOG; ++i)
          Trace[v][i] = Trace[Trace[v][i - 1]][i - 1];
        update_Hash(Hash[v], Hash[best], dig);
      }
    }
  }
  for (long long i = 2; i <= (long long)orgN; ++i)
    cout << Hash[i].code[0] << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cin >> n >> m;
  orgN = n;
  long long u, v;
  for (long long i = 1; i <= (long long)m; ++i) {
    cin >> u >> v;
    vector<long long> V;
    long long val = i;
    while (val > 0) {
      V.push_back(val % 10);
      val /= 10;
    }
    reverse(V.begin(), V.end());
    long long cur = u;
    for (long long id = 0; id < (long long)V.size(); ++id) {
      long long dig = V[id], ver = (id + 1 == (long long)V.size()) ? v : (++n);
      adj[cur].push_back(pair<long long, long long>(dig, ver));
      cur = ver;
    }
    cur = v;
    for (long long id = 0; id < (long long)V.size(); ++id) {
      long long dig = V[id], ver = (id + 1 == (long long)V.size()) ? u : (++n);
      adj[cur].push_back(pair<long long, long long>(dig, ver));
      cur = ver;
    }
  }
  sol();
  return 0;
}