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.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;


public class CFContest {
    public static void main(String[] args) throws Exception {
        boolean local = System.getProperty("ONLINE_JUDGE") == null;
        boolean async = true;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("D:\\DATABASE\\TESTCASE\\Code.in"), System.out, charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io, new Debug(local));

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        if (local) {
            io.cache.append("\n\n--memory -- \n" + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "M");
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;
        final Debug debug;
        int inf = (int) 1e8;
        long lInf = (long) 1e18;

        public Task(FastIO io, Debug debug) {
            this.io = io;
            this.debug = debug;
        }

        @Override
        public void run() {
            solve1();
        }


        public void solve1() {
            int n = io.readInt();
            int m = io.readInt();
            Node[] nodes = new Node[1 + n];

            Tries tries = new Tries();

            for (int i = 1; i <= n; i++) {
                nodes[i] = new Node();
                nodes[i].id = i;
                nodes[i].which = Tries.Node.inf;
            }

            for (int i = 1; i <= m; i++) {
                Node a = nodes[io.readInt()];
                Node b = nodes[io.readInt()];
                Edge e = new Edge();
                e.a = a;
                e.b = b;
                e.number = i;
                a.edge.add(e);
                b.edge.add(e);
            }

            TreeSet<Node> set = new TreeSet<>((a, b) -> a.which == b.which ? a.id - b.id : Tries.Node.cmp(a.which, b.which));
            nodes[1].which = tries.root;
            for (int i = 1; i <= n; i++) {
                set.add(nodes[i]);
            }


            while (!set.isEmpty()) {
                Node head = set.pollFirst();
                for (Edge e : head.edge) {
                    Node node = e.a == head ? e.b : e.a;
                    Tries.Node dist = tries.get(head.which, e.number);
                    if (Tries.Node.cmp(dist, node.which) >= 0) {
                        continue;
                    }
                    set.remove(node);
                    node.which = dist;
                    set.add(node);
                }
            }

            for (int i = 2; i <= n; i++) {
                io.cache.append(nodes[i].which.prefix).append('\n');
            }
        }

    }

    public static class Tries {
        private Node root = new Node();
        private Node inf = new Node();

        public Node get(Node since, int c) {
            Node trace = since;
            int v = 1;
            while (v * 10 <= c) {
                v *= 10;
            }
            while (v != 0) {
                trace = trace.get(c / v);
                c %= v;
                v /= 10;
            }

            return trace;
        }

        private static class Node {
            Node[] children = new Node[10];
            Node[] bl = new Node[20];
            static Node inf = new Node();
            static{
                Arrays.fill(inf.children, inf);
            }

            int depth;
            static int mod = (int) 1e9 + 7;
            int prefix;
            int c;

            private Node() {
            }

            public Node climb(int depth) {
                int diff = this.depth - depth;
                Node trace = this;
                for (int i = 0; diff >= (1 << i); i++) {
                    int bit = (1 << i);
                    if ((bit & diff) > 0) {
                        trace = trace.bl[i];
                    }
                }
                return trace;
            }

            public static int cmp(Node a, Node b) {

                if (a == inf && b == inf) {
                    return 0;
                }
                if (a == inf) {
                    return 1;
                }
                if (b == inf) {
                    return -1;
                }
                if (a == b) {
                    return 0;
                }

                if (a.depth != b.depth) {
                    return a.depth - b.depth;
                }
                int step = 19;
                while (step >= 0) {
                    if (a.bl[step] == null ||
                            a.bl[step] == b.bl[step]) {
                    } else {
                        a = a.bl[step];
                        b = b.bl[step];
                    }
                    step--;
                }
                return a.c - b.c;
            }

            public Node get(int i) {
                if (children[i] == null) {
                    children[i] = new Node();
                    children[i].c = i;
                    children[i].prefix = (int) (((long) prefix * 10 + i) % mod);
                    children[i].depth = depth + 1;
                    children[i].bl[0] = this;
                    for (int j = 0; j < 19 && children[i].bl[j] != null; j++) {
                        children[i].bl[j + 1] = children[i].bl[j].bl[j];
                    }
                }
                return children[i];
            }
        }
    }

    public static class Edge {
        Node a;
        Node b;
        int number;
    }

    public static class Node {
        List<Edge> edge = new ArrayList<>();
        Tries.Node which;
        int id;
    }


    public static class FastIO {
        public final StringBuilder cache = new StringBuilder(20 << 20);
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 8);
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        public FastIO(InputStream is, OutputStream os) {
            this(is, os, Charset.forName("ascii"));
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            boolean sign = true;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+';
                next = read();
            }

            long val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            if (next != '.') {
                return sign ? val : -val;
            }
            next = read();
            long radix = 1;
            long point = 0;
            while (next >= '0' && next <= '9') {
                point = point * 10 + next - '0';
                radix = radix * 10;
                next = read();
            }
            double result = val + (double) point / radix;
            return sign ? result : -result;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readLine(char[] data, int offset) {
            int originalOffset = offset;
            while (next != -1 && next != '\n') {
                data[offset++] = (char) next;
                next = read();
            }
            return offset - originalOffset;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public char readChar() {
            skipBlank();
            char c = (char) next;
            next = read();
            return c;
        }

        public void flush() {
            try {
                os.write(cache.toString().getBytes(charset));
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Debug {
        private boolean allowDebug;

        public Debug(boolean allowDebug) {
            this.allowDebug = allowDebug;
        }

        public void assertTrue(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (!flag) {
                fail();
            }
        }

        public void fail() {
            throw new RuntimeException();
        }

        public void assertFalse(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (flag) {
                fail();
            }
        }

        private void outputName(String name) {
            System.out.print(name + " = ");
        }

        public void debug(String name, int x) {
            if (!allowDebug) {
                return;
            }

            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, long x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, double x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, int[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, long[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, double[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, Object x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, Object... x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.deepToString(x));
        }
    }
}