open Printf
open Scanf

let id x = x

let h, w = scanf "%d %d" (fun h w -> h, w)
let vs = Array.init (h * w) (fun i -> scanf " %d" id)

let nth n =
  let y = n / w in
  let x = n mod w in
  let x' = if y mod 2 = 0 then x else w - 1 - x in
  y * w + x'

let decode n =
  let y = n / w in
  let x = n mod w in
  (y + 1, x + 1)

let () =
  let out = ref [] in
  let moving = ref false in
  for n = 0 to h * w - 1 do
    let i = nth n in
    if !moving then begin
      out := (i, n) :: !out;
      if vs.(i) mod 2 = 1 then moving := false
    end else begin
      if vs.(i) mod 2 = 1 then moving := true
    end
  done;
  out := List.rev !out;
  printf "%d\n" (List.length !out);
  List.iter (fun (v, n) ->
    let y0, x0 = decode (nth (n - 1)) in
    let y1, x1 = decode v in
    printf "%d %d %d %d\n" y0 x0 y1 x1
  ) !out;
