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 JAVA):

Solution:
import java.io.*;
import java.util.*;

public class F {

	static final long MOD = 1_000_000_007;
	static final int MAXN = 5_000_00;
	static int N,M;
	static ArrayList<Edge>[] adj, rev;
	
	static int[] length;
	static int maxLength;
	static ArrayList<Integer> atLength[];
	
	static int[] sortIndex;
	static long[] answer;
	
	public static void main(String args[]) {
		FS in = new FS();
		PrintWriter out = new PrintWriter(System.out);
		
		adj = new ArrayList[MAXN];	
		rev = new ArrayList[MAXN];
		N = in.nextInt();
		M = in.nextInt();
		int origN = N;
		for(int i = 0; i < N; i++) adj[i] = new ArrayList<>();
		for(int i = 0; i < N; i++) rev[i] = new ArrayList<>();
		for(int ei = 1; ei <= M; ei++) {
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			char[] str = (""+ei).toCharArray();
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(a);
			for(int j = 0; j < str.length-1; j++) {
				adj[N] = new ArrayList<>();
				rev[N] = new ArrayList<>();
				list.add(N++);
			}
			list.add(b);
			
			// Go forwards
			int idd = 0;
			for(int i = 0; i < list.size() - 1; i++){
				int from = list.get(i), to = list.get(i+1), digit = str[idd++]-'0';
				adj[from].add(new Edge(to, digit));
				rev[to].add(new Edge(from, digit));
			}
			// Go backwards
			idd = 0;
			for(int i = list.size()-1; i > 0; i--) {
				int from = list.get(i), to = list.get(i-1), digit = str[idd++]-'0';
				adj[from].add(new Edge(to, digit));
				rev[to].add(new Edge(from, digit));
			}
		}
		
		// bfs to get the lengths (always no leading 0s POGO)
		bfs1();
				
		// Now get a list of all nodes at a certain length
		maxLength = 0;
		for(int ii : length) maxLength = Math.max(maxLength, ii);
		atLength = new ArrayList[maxLength+1];
		for(int i = 0; i < atLength.length; i++) atLength[i] = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) atLength[length[i]].add(i);
		
		// Create an array for everything's sort index for it's length
		sortIndex = new int[N];
		answer = new long[N];
		
		// by default, sortIndex[0] = 0 because it's the only thing in his list
		for(int toSolve = 1; toSolve <= maxLength; toSolve++) {
			ArrayList<Pair> ps = new ArrayList<Pair>();
			for(int node : atLength[toSolve]) {
				Pair curBest = null;
				for(Edge e : rev[node]) {
					if(length[e.to] + 1 != length[node]) continue; // length doesn't match
					Pair next = new Pair(sortIndex[e.to], e.digit, e.to);
					if(curBest == null || curBest.compareTo(next) > 0) curBest = next;
				}
				// Create my answer and add me to pair list
				ps.add(curBest);
				answer[node] = (10*answer[curBest.id] + curBest.b)%MOD;
				curBest.id = node;
				ps.add(curBest);
			}
			Collections.sort(ps);
			int curIndex = 0;
			for(int i = 0; i < ps.size(); i++) {
				sortIndex[ps.get(i).id] = curIndex;
				// If not equal to next thing, increment curIndex
				if(i+1 < ps.size() && ps.get(i).compareTo(ps.get(i+1)) < 0) curIndex++;
			}
		}
		
		for(int i = 1; i < origN; i++) out.println(answer[i]);
		
		out.close();
	}
	
	static void bfs1() {
		length = new int[N];
		Arrays.fill(length, -1);
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(0);
		length[0] = 0;
		while(!q.isEmpty()) {
			int v = q.poll();
			for(Edge e : adj[v]) {
				if(length[e.to] == -1) {
					length[e.to] = length[v] + 1;
					q.add(e.to);
				}
			}
		}
	}
	
	static class Edge {
		int to, digit;
		public Edge(int tt, int dd) {
			to=tt;
			digit=dd;
		}
		
		@Override
		public String toString() {
			return "(to="+to+" d="+digit+")";
		}
	}
	
	static class Pair implements Comparable<Pair>{
		int a, b, id;
		public Pair(int aa, int bb, int ii) {
			a=aa;
			b=bb;
			id=ii;
		}
		@Override
		public int compareTo(Pair o) {
			if(a != o.a) return a-o.a;
			return b-o.b;
		}
	}
	
	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {st = new StringTokenizer(br.readLine());}
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		long nextLong() { return Long.parseLong(next());}
		double nextDouble() { return Double.parseDouble(next());}
	}
}