{$O-,Q+,R+}
uses SysUtils;
const MaxK = 100;
      MaxS = (MaxK + 1) * 9;
      MaxQ = MaxS * MaxS * 10;
      inf = maxint shr 1;

var l : array [0..MaxS, 0..MaxS, 0..9] of integer;
    d : integer;

function eval (s1, s2, cy : integer) : integer;
var a, z, z1, z2, bc, ec, bz, nc, ll : integer;
begin
  if (s1 < 0) or (s2 < 0) then begin
    Result := inf; exit
  end;
  if l[s1, s2, cy] >= 0 then begin eval := l[s1, s2, cy]; exit end;
  Result := inf;
  l[s1, s2, cy] := inf;
  bc := -239; ec := 239; bz := -239;
  for a := 0 to 9 do begin
    z := a * d;
    z1 := z mod 10;
    z2 := z div 10;
    if z2 = cy then begin
      bc := 0; ec := 9 - z1; bz := z1;
    end else
    if z2 = cy - 1 then begin
      bc := 10 - z1; ec := 9; bz := 0;
    end else continue;
    for nc := bc to ec do begin
      ll := eval (s1 - a, s2 - (bz + nc - bc), nc) + 1;
      if ll < Result then Result := ll;
    end;
  end;
  l[s1, s2, cy] := Result;
end;

type num = array [1..MaxK] of integer;

var y : num;
    k : integer;


procedure recover (s1, s2, cy, p : integer);
var a, z, nc, z1, z2, bc, ec, bz, ll : integer;
begin
  bc := -239; ec := 239; bz := -239;
  if p <= k then begin
    for a := 0 to 9 do begin
      z := a * d;
      z1 := z mod 10;
      z2 := z div 10;
      if z2 = cy then begin
        bc := 0; ec := 9 - z1; bz := z1;
      end else
      if z2 = cy - 1 then begin
        bc := 10 - z1; ec := 9; bz := 0;
      end else continue;
      for nc := bc to ec do begin
        ll := eval (s1 - a, s2 - (bz + nc - bc), nc);
        if ll <= k - p then begin
          y[p] := a;
          recover (s1 - a, s2 - (bz + nc - bc), nc, p + 1);
          exit;
        end;
      end;
    end;
    assert (false);
  end else assert ((s1 = 0) and (s2 = 0) and (cy = 0));
end;


var i, s, p, a, cy, nd1, nd2, ll: integer;
    x : num;
    less : boolean;

begin
  reset (input, 'digit.in'); rewrite (output, 'digit.out');
  read (k, s, p, d);
  assert ((k >= 1) and (k <= MaxK));
  assert ((s >= 1) and (s <= 9 * K));
  assert ((p >= 1) and (s <= 9 * (K + 1)));
  assert ((d >= 1) and (d <= 9));
  assert (seekeof);

  fillchar (l, sizeof (l), -1);
  l[0, 0, 0] := 0;
  x[1] := 10;
  for a := 1 to 9 do 
    for cy := 0 to 9 do begin
      nd1 := a * d + cy;
      nd2 := nd1 div 10;
      nd1 := nd1 mod 10;
      ll := eval (s - a, p - nd1 - nd2, cy);
      if ll <= k - 1 then begin
        y[1] := a;
        recover (s - a, p - nd1 - nd2, cy, 2);
        less := false;
        for i := 1 to k do
          if y[i] < x[i] then begin less := true; break end
          else
          if y[i] > x[i] then break;
        if less then x := y;
      end;
    end;
  if x[1] < 10 then begin
    for i := 1 to k do write (x[i])
  end else
    write (-1);
  writeln;
end.