{
task: rect
lang: pascal
}

uses math;

type el = record h : longint; tp : integer; end;

var maxx,maxy,n : longint;
    mas : array[1..10000] of record x1,y1,x2,y2 : longint; end;
    m : array[1..20000] of el;
    len : longint;
    pried : longint;

procedure sort(l,r: longint);
var i,j,x,x2: longint;
    y : el;
begin
 i := l;
 j := r;
 x := m[(l+r) div 2].h;
 x2 := m[(l+r) div 2].tp;
 repeat
  while (m[i].h<x) or ((m[i].h=x) and (m[i].tp>x2)) do
   inc(i);
  while (m[j].h>x) or ((m[j].h=x) and (m[j].tp<x2)) do
   dec(j);
  if not(i>j) then
   begin
    y:=m[i];
    m[i]:=m[j];
    m[j]:=y;
    inc(i);
    j:=j-1;
   end;
  until i>j;
  if l<j then sort(l,j);
  if i<r then sort(i,r);
end;

procedure swp(var x,y : longint);
var t : longint;
begin
 t := x;
 x := y;
 y := t;
end;

procedure rd;
var i,j : integer;
    F : text;
    tmp : integer;
begin
 assign(F,'rect.in'); { rect.in } { rect.out }
 reset(F);
 readln(F,maxx,maxy,n);
 tmp := 0;
 i := 1;
 for j := 1 to n do
  with mas[i] do
   begin
    readln(F,x1,y1,x2,y2);
    if not((x1 = 0) and (y1 = 0))
     then begin
      inc(tmp);
      swp(x1,x2);
      inc(i);
     end
     else inc(pried);
   end;
 close(F);
 n := tmp;
end;

procedure add(x,y : longint; tp : integer);
var a : real;
begin
 inc(len);
 m[len].tp := tp;
 if x < y
  then m[len].h := maxy
  else begin
   a := (maxx/x);
   a := a*y;
   if tp > 0
    then m[len].h := ceil(a)
    else m[len].h := floor(a);
  end;
end;

function count(var x,y : longint) : longint;
var i : integer;
    k : longint;
    max,maxh:  longint;
begin
 len := 0;
 for i := 1 to n do
  with mas[i] do
   begin
    if x1 < y1 then continue;
    add(x1,y1,1);
    add(x2,y2,-1);
   end;
 if len > 0 then sort(1,len);
 k := 0;
 max:= 0;
 maxh := 0;
 for i := 1 to len do
  begin
   k := k + m[i].tp;
   if k > max
    then begin
     max := k;
     maxh := m[i].h;
    end;
  end;
 count := max;
 x := maxx;
 y := maxh;
end;

procedure wr;
var F : text;
    ats,tmp : longint;
    i : integer;
    ax,ay,bx,by : longint;
begin
 ats := count(ax,ay);
 swp(maxx,maxy);
 for i := 1 to n do
  with mas[i] do
   begin
    swp(x1,y1);
    swp(x2,y2);
    swp(x1,x2);
    swp(y1,y2);
   end;
 tmp := count(by,bx);
 if ats < tmp
  then begin
   ats := tmp;
   ax := bx;
   ay := by;
  end;
 assign(F,'rect.out');
 rewrite(F);
 writeln(F,ats+pried,' ',ax,' ',ay);
 close(F);
end;

begin
 rd;
 wr;
end.
