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 EPS = (long double)1e-7;
const long double PI = acos(0) * 2;
bool isZero(const long double& x) { return abs(x) <= EPS; }
int sign(const long double& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
long long gcd(long long a, long long b) {
  for (; b; a %= b, swap(a, b)) {
  }
  return abs(a);
}
pair<long long, long long> operator+(const pair<long long, long long>& a,
                                     const pair<long long, long long>& b) {
  return pair<long long, long long>(a.first + b.first, a.second + b.second);
}
pair<long long, long long> operator-(const pair<long long, long long>& a,
                                     const pair<long long, long long>& b) {
  return pair<long long, long long>(a.first - b.first, a.second - b.second);
}
pair<long long, long long> operator*(const pair<long long, long long>& a,
                                     const long long& b) {
  return pair<long long, long long>(a.first * b, a.second * b);
}
long long operator*(const pair<long long, long long>& a,
                    const pair<long long, long long>& b) {
  return a.first * b.second - b.first * a.second;
}
long long ccw(const pair<long long, long long>& a,
              const pair<long long, long long>& b,
              const pair<long long, long long>& c) {
  return a * b + b * c + c * a;
}
void fg(vector<int> G[], int a, int b) {
  G[a].emplace_back(b);
  G[b].emplace_back(a);
}
void fg(vector<pair<int, int>> G[], int a, int b, int c) {
  G[a].emplace_back(b, c);
  G[b].emplace_back(a, c);
}
const int MOD = 1000000007;
const int MAXN = 100055;
const int MAXM = 100055;
const int MAXC = 600055;
int dgl[MAXM], pw10[9];
int rel[MAXN], bcd[MAXN], bidx[MAXN];
vector<pair<int, int>> G[MAXN];
vector<int> CV[MAXC];
long long Ans[MAXN];
int A[MAXM], B[MAXM];
int C[MAXN];
int N, M;
void precal() {
  for (int s = 0, e = 1, g = 0;; e++) {
    if (e >= MAXC) break;
    for (int v : CV[e]) {
      rel[v] = (0x3f3f3f3f);
      for (auto& ed : G[v]) {
        int idx, dst;
        tie(idx, dst) = ed;
        dst = C[idx] + dgl[dst];
        if (dst != C[v]) continue;
        dst = ed.second;
        int nrel = rel[idx];
        int nbcd = bcd[idx] * pw10[dgl[dst]] + dst;
        if (pair<int, int>(nrel, nbcd) < pair<int, int>(rel[v], bcd[v])) {
          rel[v] = nrel;
          bcd[v] = nbcd;
          bidx[v] = idx;
        }
      }
    }
    if (e - s < 6) continue;
    s++;
    vector<pair<int, int>> O;
    for (int i = s; i <= e; i++)
      for (int v : CV[i]) {
        int key = rel[v] * 10 + bcd[v] / pw10[i - s];
        bcd[v] %= pw10[i - s];
        O.emplace_back(key, v);
      }
    sort(((O).begin()), ((O).end()));
    for (int p = 0, q, n = ((int)(O).size()), cnt = 0; p < n; p = q) {
      for (q = p; q < n && O[p].first == O[q].first; q++)
        rel[O[q].second] = cnt;
      cnt++;
    }
  }
  for (int i = 1; i < MAXC; i++) {
    for (int v : CV[i]) {
      int pv = bidx[v];
      for (auto& ed : G[v]) {
        int idx, dst;
        tie(idx, dst) = ed;
        if (idx != pv) continue;
        Ans[v] = (Ans[idx] * pw10[dgl[dst]] + dst) % MOD;
        break;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pw10[0] = 1;
  for (int i = 1; i < 9; i++) pw10[i] = pw10[i - 1] * 10;
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> A[i] >> B[i];
    fg(G, A[i], B[i], i);
  }
  for (int i = 1; i <= M; i++) {
    int& ret = dgl[i];
    for (int j = i; j; j /= 10) ret++;
  }
  {
    fill(C + 2, C + N + 1, (0x3f3f3f3f));
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        PQ;
    PQ.emplace(0, 1);
    for (int idx, dst; !PQ.empty();) {
      tie(dst, idx) = PQ.top();
      PQ.pop();
      for (auto& ed : G[idx]) {
        int ndst, nidx;
        tie(nidx, ndst) = ed;
        ndst = dst + dgl[ndst];
        if (C[nidx] <= ndst) continue;
        C[nidx] = ndst;
        PQ.emplace(ndst, nidx);
      }
    }
  }
  for (int i = 1; i <= N; i++) CV[C[i]].emplace_back(i);
  precal();
  for (int i = 2; i <= N; i++) cout << Ans[i] << '\n';
  return 0;
}