open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done
	let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
end open MyInt64
let (@~) a (i,j) = a.(~|i).(~|j) let (<@~) a (i,j,v) = a.(~|i).(~|j) <- v

let () =
	let h,w = get_2_i64 0 in
	let a = Array.init (~|h) (fun _ -> input_i64_array w)
	in
	(* let visited = Array.make_matrix (~|h) (~|w) false in *)
	let b = Array.init (~|h) (fun i -> Array.init (~|w) (fun j -> a.(i).(j)))
	in
	let f () =
		let ls = ref [] in
		let mx,mxls = ref 0L,ref []
		in
		let valid i j = i >= 0L && i < h && j >= 0L && j < w in
		let rec f0 i j =
			if j >= w then f0 (i+1L) 0L
			else if i >= h then (
				let v = Array.fold_left (fun u c -> u + Array.fold_left (fun u v -> u + (if v=0L || v mod 2L = 0L then 1L else 0L)) 0L c) 0L b
				in if v > !mx then (mx := v; mxls := List.map (fun v -> v) !ls)
			)
			else (
				f0 i (j+1L);
				doo i j 1L 0L;
				doo i j (-1L) 0L;
				doo i j 0L 1L;
				doo i j 0L (-1L);
			)
		and doo i j u v =
			if valid i j && valid (i+u) (j+v) && b@~(i,j) > 0L then (
				b <@~ (i,j,(b@~(i,j))-1L);
				b <@~ (i+u,j+v,1L+(b@~(i+u,j+v)));
				ls := (i,j,i+u,j+v)::!ls;
				let r = f0 i (j+1L) in
				b <@~ (i+u,j+v,(b@~(i+u,j+v))-1L);
				b <@~ (i,j,(b@~(i,j))+1L);
				ls := List.tl !ls;
				r
			)
		in f0 0L 0L; !mxls
	in
	f ()
	|> (fun ls ->
		printf "%d\n" @@ List.length ls;
		List.iter (fun (p,q,r,s) -> printf "%Ld %Ld %Ld %Ld\n"
			(p+1L) (q+1L) (r+1L) (s+1L)) ls
	)
