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

public class SolutionTL implements Runnable
{

	public static void main(String[] args)
	{
		(new Thread(null, new SolutionTL(), "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());
	}

	int mod(int a, int b)
	{
		int k = String.valueOf(b).length();
		int d = 1;
		while(k != 0)
		{
			d *= 10;
			k--;
		}
		return d - a;
	}

	int getK(long a, long b)
	{
		int m = Math.abs(mod(((Long) a).intValue(), ((Long) b).intValue())), k = 0;

		boolean[] w = new boolean[m];
		int d = 1;
		do
		{
			int t = ((Long) (((b * a) % m * d - b) % m)).intValue();
			t = (t + m) % m;
			if(t == 0) { return k; }
			if(w[t]) { return -1; }

			k++;
			w[t] = true;
			d *= 10;
			d %= m;
		} while(true);
	}

	String pow10(int k)
	{
		StringBuilder res = new StringBuilder("1");
		for(int i = 0; i < k; i++) res.append('0');
		return res.toString();
	}

	void solve() throws Exception
	{
		Scanner z=new Scanner(System.in);
		int a = z.nextInt(), b = z.nextInt();
		int k = getK(a, b);
		if(k == -1)
		{
			System.out.print(-1);
			return;
		}

		// java govno
		BigInteger res = BigInteger.valueOf(b).subtract(
				new BigInteger(pow10(k)).multiply(BigInteger.valueOf(b * 1l * a))).
				divide(BigInteger.valueOf(mod(a, b))).abs();

		BigInteger res2 = new BigInteger(String.valueOf(b) + res.toString());
		if(res2.multiply(BigInteger.valueOf(a)).toString().equals(res.toString() + String.valueOf(b)))
		{
			System.out.print(res2.toString());
		}
		else
		{
			System.out.print(-1);
		}
	}

}
