import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Scanner;

public class Solution implements Runnable
{

	public static void main(String[] args)
	{
		(new Thread(null, new Solution(), "1", 1l << 28)).start();
	}

	public void run()
	{
		try
		{
			//in = new BufferedReader(new FileReader("numbers.in"));
			//out = new PrintWriter("numbers.out");
			solve();
		} catch(Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		} finally
		{
			//out.close();
		}
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = null;

	String nextToken() throws Exception
	{
		while(st == null || !st.hasMoreTokens())
		{
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

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

	String period(int a, int b)
	{
		if(a * 10 < b || a >= b) { return ""; }
		int[] v = new int[b];
		StringBuilder res = new StringBuilder();
		char[] digits = new char[10];
		for(int i = 0; i < 10; i++)
		{
			digits[i] = String.valueOf(i).charAt(0);
		}
		int count = 0;
		while(v[a] == 0)
		{
			v[a] = ++count;
			res.append(digits[(a * 10) / b]);
			a = (a * 10) % b;
		}
		if(v[a] != 1) { return ""; }
		return res.toString();
	}

	int f(int a)
	{
		int res = 10;
		while(a >= res) res *= 10;
		return res;
	}

	void solve() throws Exception
	{
	    Scanner z=new Scanner(System.in);
		int a = z.nextInt(), b = z.nextInt();
		String str = period(b, Math.abs(f(b) - a));
		if(str.length() == 0)
		{
			System.out.print(-1);
			return;
		}
		if(!str.startsWith(String.valueOf(b)))
		{
			System.out.print(-1);
			return;
		}
		System.out.print(str);
	}

}