var
  t: integer = 0;
  a, b, c, hh: integer;
  h, max: int64;
begin
  reset(input, 'tests');
  max := 1000000000;
  max := max * max;
  while not seekeof do
  begin
    inc(t);
    read(a, b, c, h);
    if (a > 100000) or (b > 100000) or (c > 100000) or (h > max) then
    begin
      rewrite(output, '');
      writeln('Invalid test ', t);
      close(output);
      halt;
    end;
    hh := h mod 500000;
    if (h >= 500000) and (hh < 100000) then
      hh := 500000;
    rewrite(output, chr(ord('0') + t div 10) + chr(ord('0') + t mod 10));
    writeln(hh);
    writeln(a, ' ', b, ' ', c);
    close(output);
  end;
  close(input);
end.