{$q+,r+,o-}

uses sysutils;

var
  i, j, n, t: integer;
  q, p, d: array[1..1000] of integer;

begin
  n := strtoint(paramstr(1));
  randseed := strtoint(paramstr(2)) * 12524;

  t := random(1000) + 1;

  writeln(n, ' ', t);

  q[1] := random(10) + 1;
  for i := 2 to n do q[i] := q[i - 1] + random(10) + 1;
  for i := 2 to n do begin
    j := random(i) + 1;
    t := q[i];
    q[i] := q[j];
    q[j] := t;
  end;
  for i := 1 to n do begin
    write(q[i]);
    if (i < n) then write(' ') else writeln;
  end;

  d[1] := random(10) + 1;
  for i := 2 to n do d[i] := d[i - 1] + random(10) + 1;
  for i := 2 to n do begin
    j := random(i) + 1;
    t := d[i];
    d[i] := d[j];
    d[j] := t;
  end;
  for i := 1 to n do begin
    write(d[i]);
    if (i < n) then write(' ') else writeln;
  end;
  
  q[1] := random(10) + 1;
  for i := 2 to n do q[i] := q[i - 1] + random(10) + 1;
  for i := 2 to n do begin
    j := random(i) + 1;
    t := q[i];
    q[i] := q[j];
    q[j] := t;
  end;
  for i := 1 to n do p[i] := t * d[i] + q[i]; 
  for i := 1 to n do begin
    write(p[i]);
    if (i < n) then write(' ') else writeln;
  end;


end.