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;
int nDigit(int x) { return x ? 1 + nDigit(x / 10) : 0; }
const int N = 600010;
const long long mod = 1e9 + 7;
int n, m;
int done[N];
int dist[N];
long long ans[N];
vector<pair<int, int> > ds[N];
int height[N];
int jump[N][20];
pair<int, int> lca(int x, int y) {
  if (x == y) return make_pair(x, x);
  for (int lg = 19; lg >= 0; --lg) {
    if (jump[x][lg] != jump[y][lg]) {
      x = jump[x][lg];
      y = jump[y][lg];
    }
  }
  return make_pair(x, y);
}
int cnt;
int cpar[N];
int trie[N][11];
string getNum(int x) {
  if (x == 0) return "";
  return getNum(x / 10) + char(x % 10 + '0');
}
void addNode(int x, int p, int c) {
  trie[p][c] = x;
  cpar[x] = c;
  height[x] = height[p] + 1;
  ans[x] = ans[p] * 10 + c;
  ans[x] %= mod;
  jump[x][0] = p;
  for (int lg = 1; lg < 20; ++lg) jump[x][lg] = jump[jump[x][lg - 1]][lg - 1];
}
int add(int start, string key) {
  for (auto &c : key) {
    c -= '0';
    if (!trie[start][c]) addNode(++cnt, start, c);
    start = trie[start][c];
  }
  return start;
}
int at[N];
map<pair<int, int>, int> idx;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    idx[make_pair(u, v)] = i;
    idx[make_pair(v, u)] = i;
    ds[u].emplace_back(v, nDigit(i));
    ds[v].emplace_back(u, nDigit(i));
  }
  memset(dist, 60, sizeof dist);
  set<pair<int, int> > pq;
  pq.emplace(dist[1] = 0, 1);
  vector<int> ordered;
  while (!pq.empty()) {
    int x = pq.begin()->second;
    pq.erase(pq.begin());
    if (done[x]) continue;
    done[x] = 1;
    ordered.push_back(x);
    for (auto &e : ds[x]) {
      if (dist[e.first] > dist[x] + e.second) {
        dist[e.first] = dist[x] + e.second;
        pq.emplace(dist[e.first], e.first);
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    int v = ordered[i];
    at[v] = -1;
    for (auto &e : ds[v]) {
      int s = e.first, w = e.second;
      if (dist[s] + w != dist[v]) continue;
      int r = add(at[s], getNum(idx[make_pair(s, v)]));
      if (at[v] == -1) {
        at[v] = r;
        continue;
      }
      auto p = lca(at[v], r);
      if (p.first == p.second) continue;
      if (cpar[p.first] > cpar[p.second]) at[v] = r;
    }
  }
  for (int i = 2; i <= n; ++i) cout << ans[at[i]] << "\n";
  return 0;
}