Program Multiple;

Const MaxQ=25; //maximal amount of ?'s
      MaxN=10000; //maximal divisor
      Infinity = Succ('9');
      Ord0 = Ord('0');

Type
    TNumber = String;
    TQuestions = String[MaxQ];
    TQList = Array [0..MaxN-1] of TQuestions;

Var f: Text;
    n: LongInt;  // divizor
    damaged: TNumber; //damaged number
    remainder: LongInt; //(damaged number with 0's in place of ?'s) mod n

    q: LongInt; //amount of ?'s
    tenPower: Array [1..MaxQ] of LongInt; //ten powers mod n

    x, y: TQList; //purpose and auxiliary arrays
    num: TNumber;
    i, j, k, dig, startDig: LongInt;
Begin
  {Read data...}
//  Assign(f, 'multiple.in'); Reset(f);
  Readln(n);
  Readln(damaged);
//  Close(f);
  {Stage 1}
  q:= 0;
  remainder:= 0;
  j:= 1; // tenPower mod n
  For i:= Length(damaged) DownTo 1 Do Begin
    If damaged[i]='?' Then Begin
      Inc(q);
      tenPower[q]:= j;
    End
    Else Begin
      k:= Ord(damaged[i])-Ord0;
      remainder:= (remainder+k*j) mod n;
    End;
    j:= (j*10) mod n;
  End;
  If damaged[1]='?' Then Begin
    startDig:= 1;
  End
  Else Begin
    startDig:= 0;
  End;

  {Stage 2}
  {2. Initialization}
  For i:= 0 To n-1 Do Begin
    x[i]:= Infinity;
    y[i]:= Infinity;
  End;
  x[0]:= '';
  {2. Processing}
  For j:= q DownTo 1 Do Begin
    For i:= 0 To n-1 Do Begin
      If (x[i]<Infinity) Then Begin
        For dig:= startDig To 9 Do Begin
          k:= (i+dig*tenPower[j]) mod n;
          num:= x[i]+Chr(dig+Ord0);
          If num<y[k] Then Begin
            y[k]:= num;
          End;
        End;
      End;
    End;
    For i:= 0 To n-1 Do Begin
      x[i]:= y[i];
      y[i]:= Infinity;
    End;
    startDig:= 0;
  End;


  {Output}
//  Assign(f, 'multiple.out'); Rewrite(f);
  If (remainder=0) Then Begin
    num:= x[0];
  End
  Else Begin
    num:= x[n-remainder];
  End;
  k:= 0;
  For i:= 1 To Length(damaged) Do Begin
    If damaged[i]='?' Then Begin
      Inc(k);
      Write(num[k]);
    End
    Else Begin
      Write(damaged[i]);
    End;
  End;
//  Writeln(f);
//  Close(f);
End.
