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 int maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
int bsize = 400;
int n, m;
vector<pair<int, int>> vect[maxn];
struct node {
  long long acval;
  string tval;
  vector<int> hval;
  int sz;
} nd[maxn];
int pos[maxn];
struct cmp {
  bool operator()(int a, int b) {
    if (nd[a].sz < nd[b].sz) return true;
    if (nd[a].sz > nd[b].sz) return false;
    for (int i = 0; i < nd[a].hval.size(); i++) {
      if (nd[a].hval[i] < nd[b].hval[i]) return true;
      if (nd[a].hval[i] > nd[b].hval[i]) return false;
    }
    if (nd[a].tval < nd[b].tval) return true;
    if (nd[a].tval > nd[b].tval) return false;
    return a < b;
    return false;
  }
};
bool cmpf(int a, int b) {
  if (nd[a].sz < nd[b].sz) return true;
  if (nd[a].sz > nd[b].sz) return false;
  for (int i = 0; i < nd[a].hval.size(); i++) {
    if (nd[a].hval[i] < nd[b].hval[i]) return true;
    if (nd[a].hval[i] > nd[b].hval[i]) return false;
  }
  if (nd[a].tval < nd[b].tval) return true;
  if (nd[a].tval > nd[b].tval) return false;
  return false;
}
set<int, cmp> st;
void rehash() {
  vector<pair<string, int>> v;
  for (set<int>::iterator it = st.begin(); it != st.end(); it++) {
    int id = (*it);
    v.push_back({nd[id].tval.substr(0, bsize), id});
  }
  sort(v.begin(), v.end());
  int cnt = 1;
  nd[v[0].second].tval.erase(0, bsize);
  nd[v[0].second].hval.push_back(cnt);
  for (int i = 1; i < v.size(); i++) {
    if (v[i].first != v[i - 1].first) cnt++;
    nd[v[i].second].tval.erase(0, bsize);
    nd[v[i].second].hval.push_back(cnt);
  }
}
int ats(int x, int w) {
  int niz[6];
  int br = 0;
  while (w) {
    niz[br++] = w % 10;
    w /= 10;
  }
  int ret = br;
  while (br--) {
    nd[x].tval.push_back(niz[br] + '0');
    nd[x].sz++;
    nd[x].acval *= 10;
    nd[x].acval += niz[br];
    nd[x].acval %= mod;
  }
  return ret;
}
void efs(int x, int br, long long val) {
  nd[x].acval = val;
  for (int i = 1; i <= br; i++) {
    nd[x].sz--;
    nd[x].tval.pop_back();
  }
}
void go() {
  memset(pos, 0, sizeof(pos));
  int x = 1;
  st.insert(x);
  pos[x] = 1;
  while (st.size()) {
    x = (*st.begin());
    if (nd[x].tval.size() > bsize) rehash();
    pos[x] = 1;
    st.erase(st.begin());
    for (int i = 0; i < vect[x].size(); i++) {
      int id = vect[x][i].first;
      int w = vect[x][i].second;
      if (pos[id]) continue;
      if (nd[id].sz == 0) {
        st.erase(id);
        nd[id] = nd[x];
        ats(id, w);
        st.insert(id);
      } else {
        long long pom2 = nd[x].acval;
        int pom = ats(x, w);
        if (cmpf(x, id)) {
          st.erase(id);
          nd[id] = nd[x];
          st.insert(id);
        }
        efs(x, pom, pom2);
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    vect[u].push_back({v, i});
    vect[v].push_back({u, i});
  }
  go();
  for (int i = 2; i <= n; i++) {
    printf("%lld\n", nd[i].acval);
  }
  return 0;
}