/*=============================================================================
	Copyright (c) 2002-2010 Joel de Guzman

	Distributed under the Boost Software License, Version 1.0. (See accompanying
	file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
///////////////////////////////////////////////////////////////////////////////
//
//  A parser for summing a comma-separated list of numbers using phoenix.
//
//  [ JDG June 28, 2002 ]   spirit1
//  [ JDG March 24, 2007 ]  spirit2
//
///////////////////////////////////////////////////////////////////////////////

//#include <boost/config/warning_disable.hpp>
//[tutorial_adder_includes
//#include <boost/spirit/include/qi.hpp>
//#include <boost/spirit/include/phoenix_core.hpp>
//#include <boost/spirit/include/phoenix_operator.hpp>
//#include <boost/spirit/include/phoenix_stl.hpp>
//#include <boost/ref.hpp>
#include <iostream>
#include <fstream>
#include <string>
//#include <boost/algorithm/string.hpp>
//#include <boost/lexical_cast.hpp>
//#include <boost/lambda/lambda.hpp>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

std::string period(int a, int b)
{
	if(a * 10 < b || a >= b) return "";
	std::vector<int> v(b, 0);
	std::string res;
	std::string digits[10];
	for(int i = 0; i < 10; i++)
	{
		digits[i].resize(1);
		digits[i][0] = '0' + i;
	}
	int count = 0;
	while(!v[a])
	{
		v[a] = ++count;
		res.append(digits[(a * 10) / b]);
		a = (a * 10) % b;
	}
	if(v[a] != 1) return "";
	return res;
}

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

std::string inttostr(int a)
{
	std::ostringstream os;
	os << a;
	return os.str();
}

int numlen(int a)
{
	if(a < 10) return 1;
	return numlen(a / 10) + 1;
}

int main()
{
	//std::ifstream cin("numbers.in");
	int a, b;
	cin >> a >> b;
	std::string str = period(b, abs(f(b) - a));
	//std::ofstream cout("numbers.out");
	if(str.empty()) 
	{
		cout << -1;
		return 0;
	}
	if(str.substr(0, numlen(b)) != inttostr(b))
	{
		cout << -1;
		return 0;
	}
	cout << str;
}
