program P6;

{$APPTYPE CONSOLE}
 {$o-}
uses
  SysUtils;

var  y,d,st,j,n,i,a,b,k,t,r:longint;
     m:longint;
     code:integer;
     s,s1,ch:string[8];
function NOD(a,b:longint):longint;
 begin
  if (a=0)or(b=0) then nod:=a+b
  else if a>b then nod:=nod(a mod b,b)
              else nod:=nod(a,b mod a);
 end;

function step(x,m:longint):longint;
var t:longint;
begin
  if m=1 then
   begin step:=x;exit end
   else
   begin
    if odd(m)
     then step:=x*sqr(step(x,m div 2))
     else step:=sqr(step(x,m div 2));
   end;
end;

 begin
 //reset(input,'numbers.in');
 //rewrite(output,'numbers.out');
 read(a,b);
  str(b,s1);
   s:='';
   m:=b;k:=length(s1);st:=1;
     st:=step(10,k);
      n:=st-a;
      d:=nod(m,n);
      n:= n div d;
      m:=m div d;
      y:=m;
          if (n mod 2 = 0) or (n mod 5 = 0) or (n = 1)
           then begin write(-1);halt(0) end;
           r:=0;t:=m;
            for i := 1 to k do begin
         r := 10 * r + 10 * t div n;
         t := 10 * t mod n;
     end;
         if r <> b then begin write(-1);halt(0) end;;

   repeat
     write(10 * m div n);
      m := 10 * m mod n;
     until m = y;

end.


