function Next(a: Char): Char;
begin
  if a = '9' then Result := 'A' else Result := Succ(a);
end;

var
  a, b, N: String;
  i, L: Integer;
  m: Char;
  f: TextFile;
label
  ex;
begin
  Assign(f, 'input.txt'); Reset(f);
  Readln(f, N);
  CloseFile(f);
  L := Length(N);
  if N[L] <> 'Z' then
    a := Copy(N, 1, L - 1) + Next(N[L])
  else
    a := '';
  b := '';
  if N = '0' then goto ex;
  m := N[L];
  for i := 1 to L - 1 do
    if N[i] > m then goto ex;
  b := N;
  for i := L downto 1 do begin
    if N[i] <> m then begin
      b[i] := Next(b[i]);
      goto ex;
    end;
    b[i] := '0';
  end;
  b := '1' + b;
  ex:
  if a > b then begin N := a; a := b; b := N; end;
  Assign(f, 'output.txt'); Rewrite(f);
  if a <> '' then Writeln(f, a);
  if b <> '' then Writeln(f, b);
  CloseFile(f);
end.
