Problem: You are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s.

Input

The first line contains two positive integers d and s (1 ≤ d ≤ 500, 1 ≤ s ≤ 5000) separated by space.

Output

Print the required number or -1 if it doesn't exist.

Examples

Input

13 50


Output

699998


Input

61 2


Output

1000000000000000000000000000001


Input

15 50


Output

-1

Solution (in JAVA):

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

public class Q7
{
    static InputReader in;
    static PrintWriter out;
    
    public static void main(String[] args)
    {

        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        int t = 1;
        
        while(t-- > 0) {
            int d = in.nextInt();
            int s = in.nextInt();
            
            boolean[][] vis = new boolean[d][s + 10];
            Queue<State> q = new LinkedList<>();
            q.add(new State(0, 0));
            vis[0][0] = true;
            int[][] val = new int[d][s + 10];
            int[][][] par = new int[d][s + 10][2];
            boolean ok = false;
            val[0][0] = 0;
            
            while(!q.isEmpty()) {
                State p = q.poll();
                if(p.s > s) continue;
                if(p.s == s && p.d == 0) {
                    ok = true;
                    Stack<Integer> st = new Stack<>();
                    while(!(par[p.d][p.s][0] == p.d && par[p.d][p.s][1] == p.s)) {
                        st.add(val[p.d][p.s]);
                        int x = par[p.d][p.s][0];
                        int y = par[p.d][p.s][1];
                        p.d = x;
                        p.s = y;
                    }
                    while(!st.isEmpty()) out.print(st.pop());
                    out.println();
                    break;
                }
                vis[p.d][p.s] = true;
                for(int i = 0; i < 10; i++) {
                    int x = (p.d * 10 + i) % d;
                    int y = (p.s + i);                    
                    if(vis[x][y]) continue;
                    vis[x][y] = true;
                    q.add(new State(x, y));
                    par[x][y][0] = p.d;
                    par[x][y][1] = p.s;
                    val[x][y] = i;
                }
            }
            if(ok) continue;
            out.println(-1);
        }
        
        out.close();
    }
    
    static class State{
        int d;
        int s;

        public State(int d, int s) {
            this.d = d;
            this.s = s;
        }
        
    }
    
    static void debug(Object... o)
    {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader
    {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
                this.stream = stream;
        }

        public int snext()
        {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars)
                {
                        curChar = 0;
                        try
                        {
                                snumChars = stream.read(buf);
                        } catch (IOException e)
                        {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

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

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

        public String readString()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }

        public String nextLine()
        {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c)
        {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter
        {
                public boolean isSpaceChar(int ch);
        }

    }
}