{
TASK: VSKLY
LANG: PASCAL
}

program vskly;
  const inpFile = 'SKLYPAS.IN';
        outFile = 'SKLYPAS.OUT';
  var f: text;
      i, n: integer;
      sx0, sy0, sx1, sy1: integer;
      nx0, ny0, nx1, ny1: integer;

  function min(a, b : integer): integer;
  begin
    if a < b
      then min := a
      else min := b;
  end;

  function max(a, b : integer): integer;
  begin
    if a > b
      then max := a
      else max := b;
  end;

  procedure sankirta(var sx0, sy0, sx1, sy1: integer; nx0, ny0, nx1, ny1: integer);
    var x0, y0, x1, y1: integer;
  begin
    x0 := max(sx0, nx0);
    y0 := min(sy0, ny0);
    x1 := min(sx1, nx1);
    y1 := max(sy1, ny1);

    sx0 := x0;
    sy0 := y0;
    sx1 := x1;
    sy1 := y1;
  end;

begin
  sx0 := -1000000;
  sy0 := 1000000;
  sx1 := 1000000;
  sy1 := -1000000;

  assign(f, inpFile);
  reset(f);
  readln(f, n);
  for i := 1 to n do
    begin
      readln(f, nx0, ny0, nx1, ny1);
      sankirta(sx0, sy0, sx1, sy1, nx0, ny0, nx1, ny1);
    end;
  close(f);

  assign(f, outFile);
  rewrite(f);
  if (sx0 >= sx1) or (sy0 <= sy1)
    then writeln(f, 0)
    else writeln(f, sx0, ' ', sy0, ' ', sx1, ' ', sy1);
  close(f);
end.
