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;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
inline ll randint(ll a, ll b) {
  ll w = (_g() << 31LL) ^ _g();
  return a + w % (b - a + 1);
}
inline void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
};
template <typename T>
inline T sign(T x) {
  return T(x > 0) - T(x < 0);
}
template <typename T, typename S>
inline ostream& operator<<(ostream& os, const pair<T, S> p) {
  cout << "[" << p.first << ";" << p.second << "]";
  return os;
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
template <typename T>
inline T fetch() {
  T ret;
  cin >> ret;
  return ret;
}
template <typename T>
inline void goodbye(const T& val) {
  cout << val << '\n';
  exit(0);
}
const int MAX_N = (int)1e6 + 777;
const int MOD = (int)1e9 + 7;
int add(int x, int y) { return (x + y >= MOD ? x + y - MOD : x + y); }
int mult(int x, int y) { return (x * 1LL * y) % MOD; }
vector<pii> g[MAX_N];
int n, m, last;
int dist[MAX_N], __Abacaba[MAX_N], head = 0;
int answ[MAX_N], met[MAX_N];
vector<int> layers[MAX_N];
int cls[MAX_N];
pii pr[MAX_N];
void add_edge(int v, int u, int digit) { g[v].emplace_back(u, digit); }
void build_long_edge(int v, int u, int id) {
  vector<int> digits;
  for (; id > 0; id /= 10) digits.push_back(id % 10);
  reverse(digits.begin(), digits.end());
  vector<int> path = {v};
  for (int i = 0; i < ((int)(digits).size()) - 1; ++i) path.push_back(last++);
  path.push_back(u);
  for (int i = 0; i + 1 < ((int)(path).size()); ++i)
    add_edge(path[i], path[i + 1], digits[i]);
}
void run_bfs(int src) {
  for (int v = 0; v < last; ++v) dist[v] = INT_INF;
  dist[src] = 0;
  __Abacaba[head++] = src;
  layers[0].push_back(src);
  for (int j = 0; j < head; ++j) {
    int v = __Abacaba[j];
    for (auto& ed : g[v]) {
      int u = ed.first;
      if (dist[u] > dist[v] + 1) {
        dist[u] = dist[v] + 1;
        layers[dist[u]].push_back(u);
        __Abacaba[head++] = u;
      }
    }
  }
}
void build_cls() {
  for (int lay = 1; !layers[lay].empty(); ++lay) {
    for (auto& v : layers[lay]) pr[v] = make_pair(INT_INF, INT_INF);
    for (auto& parent : layers[lay - 1]) {
      for (auto& ed : g[parent]) {
        int v = ed.first;
        if (dist[v] == lay)
          pr[v] = min(pr[v], make_pair(cls[parent], ed.second));
      }
    }
    vector<pii> ord;
    for (auto& v : layers[lay]) ord.push_back(pr[v]);
    sort(ord.begin(), ord.end());
    for (auto& v : layers[lay])
      cls[v] = lower_bound(ord.begin(), ord.end(), pr[v]) - ord.begin();
  }
}
void build_answ(int v, int cur) {
  met[v] = 1;
  answ[v] = cur;
  for (auto& ed : g[v]) {
    int u = ed.first;
    if (dist[u] != dist[v] + 1 || met[u]) continue;
    if (pr[u] == make_pair(cls[v], ed.second))
      build_answ(u, add(mult(cur, 10), ed.second));
  }
}
void solve() {
  cin >> n >> m;
  last = n;
  for (int i = 0; i < m; ++i) {
    int v, u;
    cin >> v >> u;
    --v, --u;
    build_long_edge(v, u, i + 1);
    build_long_edge(u, v, i + 1);
  }
  run_bfs(0);
  build_cls();
  build_answ(0, 0);
  for (int v = 1; v < n; ++v) cout << answ[v] << '\n';
}
int main() {
  fast_io();
  solve();
  return 0;
}