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;
template <typename U, typename V>
void Min(U &a, const V &b) {
  if (a > b) a = b;
}
template <typename U, typename V>
void Max(U &a, const V &b) {
  if (a < b) a = b;
}
template <typename U, typename V>
void add(U &a, const V &b) {
  a = (a + b) % 1000000007;
}
template <typename U>
U gcd(U a, U b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a >= b)
    return gcd(a - b, b);
  else
    return gcd(a, b - a);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
vector<pair<int, string>> g[100005];
const int M = 100005 * 10;
int w[M], f[M][19], l[M], t[M][10], ed[100005];
char ch[M];
int sz = 0;
vector<pair<int, int>> his;
int ins(int p, string &s) {
  for (const char &c : s) {
    int j = c - '0';
    if (!t[p][j]) {
      his.push_back({p, j});
      t[p][j] = ++sz;
      for (int k = 0; k < 10; k++) t[sz][k] = 0;
      f[sz][0] = p;
      for (int i = 1; i < 19; i++) f[sz][i] = f[f[sz][i - 1]][i - 1];
      l[sz] = l[p] + 1;
      w[sz] = (w[p] * 29LL + c) % 1000000007;
      ch[sz] = c;
    }
    p = t[p][j];
  }
  return p;
}
int cmp(int first, int second) {
  if (l[first] > l[second]) return 1;
  if (l[first] < l[second]) return 0;
  int u = first, v = second;
  for (int i = 19 - 1; i >= 0; i--) {
    int p = f[u][i], q = f[v][i];
    if (w[p] != w[q]) {
      u = p, v = q;
    }
  }
  return ch[u] > ch[v];
}
int ans[100005], vis[100005];
set<int> id[M];
void dfs(int u, int w = 0) {
  for (auto &v : id[u]) {
    ans[v] = w;
  }
  for (int i = 0; i < 10; i++)
    if (t[u][i]) {
      dfs(t[u][i], (w * 10LL + i) % 1000000007);
    }
}
int main() {
  int T, m, n, i, j, k, K;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &j, &k);
    j--, k--;
    g[j].push_back({k, to_string(i + 1)});
    g[k].push_back({j, to_string(i + 1)});
  }
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    int rt = ed[u];
    for (auto &o : g[u]) {
      int v = o.first;
      if (v == 0) continue;
      int pr = sz;
      his.clear();
      int p = ins(rt, o.second);
      if (ed[v] == 0 || cmp(ed[v], p) > 0) {
        if (ed[v]) id[ed[v]].erase(v);
        ed[v] = p;
        id[p].insert(v);
        if (!vis[v]) vis[v] = 1, q.push(v);
      } else {
        for (int i = int(his.size()) - 1; i >= 0; i--) {
          t[his[i].first][his[i].second] = 0;
        }
        sz = pr;
      }
    }
  }
  dfs(0);
  for (int i = 1; i < n; i++) printf("%d\n", ans[i]);
}