program chislo_mk;
uses SysUtils, Math;
var  a, b, bb, c, d, i, k, m, n, s : longint;
Procedure NO;
     begin
       write(-1); close(output); halt;
     end;
function nod(a, b: integer): integer;
     begin
         while (a <> 0) and (b <> 0) do
            if a > b then a := a - b else b := b - a;
         if a = 0 then nod := b else nod := a;
     end;
begin
     //assign(input, 'numbers.in');   reset(input);
     //assign(output, 'numbers.out'); rewrite(output);
     read(a, b);   bb := b;
         n := Trunc(log10(b)) + 1;
         c := Trunc(IntPower(10, n)) - a;
         d := nod(b, c);
         b := b div d;    c := c div d;
         if (c mod 2 = 0) or (c mod 5 = 0) or (c = 1) then NO;
         s := 0;   k := b;   m := b;
     for i := 1 to n do begin
         s := 10 * s + 10 * k div c;
         k := 10 * k mod c;
     end;
         if s <> bb then NO;
     repeat
         write(10 * m div c);
         m := 10 * m mod c;
     until m = b;
     close(output);
end.