Problem: Suppose you have a special x-y-counter. This counter can store some value as a decimal number; at first, the counter has value 0. 

The counter performs the following algorithm: it prints its lowest digit and, after that, adds either x or y to its value. So all sequences this counter generates are starting from 0. For example, a 4-2-counter can act as follows:

  1. it prints 0, and adds 4 to its value, so the current value is 4, and the output is 0; 
  2. it prints 4, and adds 4 to its value, so the current value is 8, and the output is 04; 
  3. it prints 8, and adds 4 to its value, so the current value is 12, and the output is 048; 
  4. it prints 2, and adds 2 to its value, so the current value is 14, and the output is 0482; 
  5. it prints 4, and adds 4 to its value, so the current value is 18, and the output is 04824. 



This is only one of the possible outputs; for example, the same counter could generate 0246802468024 as the output, if we chose to add 2 during each step.

You wrote down a printed sequence from one of such x-y-counters. But the sequence was corrupted and several elements from the sequence could be erased.

Now you'd like to recover data you've lost, but you don't even know the type of the counter you used. You have a decimal string s — the remaining data of the sequence. 

For all 0 ≤ x, y < 10, calculate the minimum number of digits you have to insert in the string s to make it a possible output of the x-y-counter. Note that you can't change the order of digits in string s or erase any of them; only insertions are allowed.

Input

The first line contains a single string s (1 ≤ |s| ≤ 2 ⋅ 10^6, s_i ∈ \{0 - 9\}) — the remaining data you have. It's guaranteed that s_1 = 0.

Output

Print a 10 × 10 matrix, where the j-th integer (0-indexed) on the i-th line (0-indexed too) is equal to the minimum number of digits you have to insert in the string s to make it a possible output of the i-j-counter, or -1 if there is no way to do so.

Example

Input


0840


Output


-1 17 7 7 7 -1 2 17 2 7 
17 17 7 5 5 5 2 7 2 7 
7 7 7 4 3 7 1 7 2 5 
7 5 4 7 3 3 2 5 2 3 
7 5 3 3 7 7 1 7 2 7 
-1 5 7 3 7 -1 2 9 2 7 
2 2 1 2 1 2 2 2 0 1 
17 7 7 5 7 9 2 17 2 3 
2 2 2 2 2 2 0 2 2 2 
7 7 5 3 7 7 1 3 2 7 

Note

Let's take, for example, 4-3-counter. One of the possible outcomes the counter could print is 0(4)8(1)4(7)0 (lost elements are in the brackets).

One of the possible outcomes a 2-3-counter could print is 0(35)8(1)4(7)0.

The 6-8-counter could print exactly the string 0840.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

public class Main2 {

    static long mod = 998244353;
    static FastScanner scanner;

    static int[][][] precalc = new int[10][10][10];

    public static void main(String[] args) {
        scanner = new FastScanner();
        /*StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 500000; i++) {
            builder.append("0840");
        }*/
        for (int x = 0; x < 10; x++) {
            for (int y = 0; y < 10; y++) {
                for (int target = 0; target < 10; target++) {
                    precalc[x][y][target] = -1;

                    aaa:
                    for (int len = 1; len < 100; len++) {
                        for (int a = 0; a <= len; a++) {
                            int check = (a * y + x * (len - a)) % 10;
                            if (check == target) {
                                precalc[x][y][target] = len;
                                break aaa;
                            }
                        }
                    }
                }

            }
        }
        char[] s = scanner.nextLine().toCharArray();
        int[][] res = new int[10][10];
        for (int x = 0; x < 10; x++) {
            for (int y = x; y < 10; y++) {
                int length = 1;
                int prevLength = 1;

                boolean impos = false;
                for (int i = 1; i < s.length; i++) {
                    int prev = s[i - 1] - '0';
                    int digit = s[i] - '0';
                    length = isAchivable(x, y, prev, digit, length, prevLength);
                    if (length == -1) {
                        impos = true;
                        break;
                    }
                    prevLength = length;
                }
                if (impos) res[x][y] = res[y][x] = -1;
                else res[x][y] = res[y][x] = length - s.length;
            }
        }
        StringBuilder resS = new StringBuilder();
        for (int x = 0; x < 10; x++) {
            for (int y = 0; y < 10; y++) {
                resS.append(res[x][y]).append(' ');
            }
            resS.append('\n');
        }
        System.out.println(resS.toString());
    }

    static int isAchivable(int x, int y, int prev, int cur, int len, int prevLength) {
        int target = cur - prev;
        target = target < 0 ? target + 10 : target;
        int incLength = precalc[x][y][target];
        if (incLength == -1) return -1;
        return len + incLength;
        /*while (len - prevLength <= 10) {
            int curLen = len - prevLength;
            if (y == x) {
                if (target == (y * curLen) % 10) return len;
            } else {
                int eq = target - ((x * curLen) % 10);
                eq = eq < 0 ? eq + 10 : eq;
                int a = precalc[y - x][eq];
                if (a <= curLen) return len;
                /*if (eq % (y - x) == 0 || (10 + eq) % (y - x) == 0) {
                    int a = eq / (y - x);
                    if (a <= curLen) {
                        int goal = (prev + a * y + (curLen - a) * x) % 10;
                        if (goal == cur) return len;
                    }
                }
            }
            len++;
        }
        return -1;*/
    }

    static void solve() {
        String x = new StringBuilder(scanner.nextLine()).reverse().toString();
        String y = new StringBuilder(scanner.nextLine()).reverse().toString();
        int firstOne = 0;
        for (int i = 0; i < y.length(); i++) {
            if (y.charAt(i) == '1') {
                firstOne = i;
                break;
            }
        }

        int firstOneX = 0;
        for (int i = firstOne; i < x.length(); i++) {
            if (x.charAt(i) == '1') {
                firstOneX = i;
                break;
            }
        }

        int k = firstOneX - firstOne;
        System.out.println(k);
    }

    static class WithIdx implements Comparable<WithIdx>{
        int val, idx;

        public WithIdx(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }

        @Override
        public int compareTo(WithIdx o) {
            return Integer.compare(val, o.val);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException();
            }
        }

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

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

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

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

        long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) res[i] = nextLong();
            return res;
        }

        String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) res[i] = nextToken();
            return res;
        }
    }

    static class PrefixSums {
        long[] sums;

        public PrefixSums(long[] sums) {
            this.sums = sums;
        }

        public long sum(int fromInclusive, int toExclusive) {
            if (fromInclusive > toExclusive) throw new IllegalArgumentException("Wrong value");
            return sums[toExclusive] - sums[fromInclusive];
        }

        public static PrefixSums of(int[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }

        public static PrefixSums of(long[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }
    }

    static class ADUtils {
        static void sort(int[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                int a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }

        static void reverse(int[] arr) {
            int last = arr.length / 2;
            for (int i = 0; i < last; i++) {
                int tmp = arr[i];
                arr[i] = arr[arr.length - 1 - i];
                arr[arr.length - 1 - i] = tmp;
            }
        }

        static void sort(long[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                long a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }
    }

    static class MathUtils {
        static long[] FIRST_PRIMES = {
                2,     3,      5,      7,     11,     13,     17,     19,     23,     29,
                31,     37,     41,     43,     47,     53,     59,     61,     67,     71,
                73,     79,     83,     89  ,   97 ,    101,    103,    107,    109,    113,
                127,    131,    137,    139,    149,    151,    157,    163,    167,    173,
                179,    181,    191,    193,    197,    199,    211,    223,    227,    229,
                233,    239,    241,    251,    257,    263,    269,    271,    277,    281,
                283,    293,    307,    311,    313,    317,    331,    337,    347,    349,
                353,    359,    367,    373,    379,    383,    389,    397,    401,    409,
                419,    421,    431,    433,    439,    443,    449,    457,    461,    463,
                467,    479,    487,    491,    499,    503,    509,    521,    523,    541,
                547,    557,    563,    569,    571,    577,    587,    593,    599,    601,
                607,    613,    617,    619,    631,    641,    643,    647,    653,    659,
                661,    673,    677,    683,    691,    701,    709,    719,    727,    733,
                739,    743,    751,    757,    761,    769,    773,    787,    797,    809,
                811,    821,    823,    827,    829,    839,    853,    857,    859,    863,
                877,    881,    883,    887,    907,    911,    919,    929,    937,    941,
                947,    953,    967,    971,    977,    983,    991,    997,   1009,   1013,
                1019,   1021,   1031,   1033,   1039,   1049,   1051};

        static long[] primes(int to) {
            long[] all = new long[to + 1];
            long[] primes = new long[to + 1];
            all[1] = 1;
            int primesLength = 0;
            for (int i = 2; i <= to; i ++) {
                if (all[i] == 0) {
                    primes[primesLength++] = i;
                    all[i] = i;
                }
                for (int j = 0; j < primesLength && i * primes[j] <= to && all[i] >= primes[j]; j++) {
                    all[(int) (i * primes[j])] = primes[j];
                }
            }
            return Arrays.copyOf(primes, primesLength);
        }

        static long modpow(long b, long e, long m) {
            long result = 1;

            while (e > 0) {
                if ((e & 1) == 1) {
                    /* multiply in this bit's contribution while using modulus to keep
                     * result small */
                    result = (result * b) % m;
                }
                b = (b * b) % m;
                e >>= 1;
            }

            return result;
        }

        static long submod(long x, long y, long m) {
            return (x - y + m) % m;
        }
    }
}

/*
3 5 4 2
1 2
2 3
2 5
3 1
1 5
 */