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.*;
import java.math.BigInteger;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class F extends PrintWriter {

    final long mod = 1_000_000_000 + 7;

    int k = 20;

    class Node implements Comparable<Node> {
        final int len;
        final long hash;
        final int id;
        final int d;
        final Node[] p = new Node[k];

        public Node(Node p, int d, int id) {
            this.id = id;
            this.d = d;

            if (p == null) {
                Arrays.fill(this.p, this);
                this.len = 0;
                this.hash = d;
            } else {
                this.len = p.len + 1;
                this.hash = (((p.hash * 10) % mod) + d) % mod;

                this.p[0] = p;
                for (int h = 1; h < k; h++) {
                    this.p[h] = this.p[h - 1].p[h - 1];
                }
            }

        }

        @Override
        public int compareTo(Node node) {
            return compare(this, node);
        }
    }

    int compare(Node a, Node b) {
        int cmp = compareD(a, b);

        // println(cmp == Long.compare(a.hash, b.hash));

        return cmp;
    }

    int compareD(Node a, Node b) {
        if (a.len != b.len) {
            return Integer.compare(a.len, b.len);
        }
        if (a.len == 1) {
            return Integer.compare(a.d, b.d);
        }
        if (a.hash == b.hash) {
            return 0;
        }

        for (int h = k - 1; h >= 0; h--) {
            if (a.p[h].hash != b.p[h].hash) {
                return compare(a.p[h], b.p[h]);
            }
        }

        return Integer.compare(a.d, b.d);
    }

    Node get(Node cur, int id, int num) {

        int dd = 1;
        int dn = num;
        while (dn > 0) {
            dd *= 10;
            dn /= 10;
        }
        // println(num);

        dd /= 10;

        while (dd > 0) {
            int h = num / dd;
            // println(h + " " + num + " " + dd);
            cur = new Node(cur, h, id);
            num -= h * dd;
            dd /= 10;
        }

        return cur;

    }

    class Edge {
        final int id, u, v;

        public Edge(int id, int u, int v) {
            this.id = id;
            this.u = u;
            this.v = v;
        }

        int to(int from) {
            if (from == u) {
                return v;
            } else {
                return u;
            }
        }

    }

    void run() {
        int n = nextInt();
        int m = nextInt();
        Node[] min = new Node[n + 1];

        List<Edge>[] g = new List[n + 1];

        for (int i = 0; i <= n; i++) {
            g[i] = new ArrayList<Edge>();
        }

        for (int i = 1; i <= m; i++) {
            int u = nextInt(), v = nextInt();

            Edge edge = new Edge(i, u, v);
            g[u].add(edge);
            g[v].add(edge);
        }

        Node s = min[1] = new Node(null, 0, 1);
        PriorityQueue<Node> queue = new PriorityQueue<>();
        queue.add(s);

        while (!queue.isEmpty()) {
            Node node = queue.poll();
            if (min[node.id].compareTo(node) == 0) {
                for (Edge edge : g[node.id]) {
                    int v = edge.to(node.id);
                    Node tmp = get(node, v, edge.id);
                    // println(v + " " + tmp.hash);

                    if (min[v] == null || min[v].compareTo(tmp) > 0) {
                        min[v] = tmp;
                        queue.add(tmp);

                    }
                }
            }
        }
        // println(Arrays.toString(min));

        for (int i = 2; i <= n; i++) {
            println(min[i].hash);
        }

    }

    void skip() {
        while (hasNext()) {
            next();
        }
    }

    int[][] nextMatrix(int n, int m) {
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                matrix[i][j] = nextInt();
        return matrix;
    }

    String next() {
        while (!tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(nextLine());
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (!tokenizer.hasMoreTokens()) {
            String line = nextLine();
            if (line == null) {
                return false;
            }
            tokenizer = new StringTokenizer(line);
        }
        return true;
    }

    int[] nextArray(int n) {
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException err) {
            return null;
        }
    }

    public F(OutputStream outputStream) {
        super(outputStream);
    }

    static BufferedReader reader;
    static StringTokenizer tokenizer = new StringTokenizer("");
    static Random rnd = new Random();
    static boolean OJ;

    public static void main(String[] args) throws IOException {
        OJ = System.getProperty("ONLINE_JUDGE") != null;
        F solution = new F(System.out);
        if (OJ) {
            reader = new BufferedReader(new InputStreamReader(System.in));
            solution.run();
        } else {
            reader = new BufferedReader(new FileReader(new File(F.class.getName() + ".txt")));
            long timeout = System.currentTimeMillis();
            while (solution.hasNext()) {
                solution.run();
                solution.println();
                solution.println("----------------------------------");
            }
            solution.println("time: " + (System.currentTimeMillis() - timeout));
        }
        solution.close();
        reader.close();
    }
}