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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T russian(T a, T b, T mod) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (a + a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const long long T = 1 << 20;
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const int LOG = 17;
int n, m, k, q;
vector<vector<pair<int, int>>> G(N);
int counter;
void gen(int pocz, int kon, int val) {
  int pom = val;
  for (int i = 0; i < 2; i++) {
    val = pom;
    int akt = kon;
    while (val) {
      if (val < 10)
        G[pocz].push_back({akt, val});
      else {
        G[counter].push_back({akt, val % 10});
        akt = counter++;
      }
      val /= 10;
    }
    swap(pocz, kon);
  }
}
int odw[N];
int dist[N];
int ans[N];
vector<vector<pair<int, int>>> DAG(N);
void solve(vector<int> &zbior, long long modulo) {
  vector<int> id;
  id.resize((int)(zbior).size());
  fill((id).begin(), (id).end(), 0);
  for (auto &u : zbior) {
    ans[u] = modulo;
    sort((DAG[u]).begin(), (DAG[u]).end());
  }
  for (int i = 0; i <= 9; i++) {
    vector<int> next;
    for (int j = 0; j < ((int)(zbior).size()); j++) {
      while (id[j] < (int)(DAG[zbior[j]]).size() &&
             i == DAG[zbior[j]][id[j]].first) {
        if (!odw[DAG[zbior[j]][id[j]].second]) {
          odw[DAG[zbior[j]][id[j]].second] = true;
          next.push_back(DAG[zbior[j]][id[j]].second);
        }
        id[j]++;
      }
    }
    if ((int)(next).size()) solve(next, (modulo * 10 + i) % INF);
  }
}
void gen_dag() {
  queue<int> kol;
  kol.push(1);
  odw[1] = 1;
  while ((int)(kol).size()) {
    int akt = kol.front();
    kol.pop();
    for (auto &u : G[akt])
      if (!odw[u.first]) {
        odw[u.first] = 1;
        dist[u.first] = dist[akt] + 1;
        kol.push(u.first);
        DAG[akt].push_back({u.second, u.first});
      } else if (dist[akt] + 1 == dist[u.first])
        DAG[akt].push_back({u.second, u.first});
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  counter = n + 1;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    gen(a, b, i);
  }
  gen_dag();
  vector<int> start = {1};
  fill(odw, odw + N, 0);
  solve(start, 0);
  for (int i = 2; i <= n; i++) cout << ans[i] << '\n';
}