program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,j,x,y,h,w
    integer(int32):: d,nx,ny,ans=0
    integer(int32), allocatable:: a(:,:),ax1(:),ay1(:),ax2(:),ay2(:)
    logical,allocatable:: pass(:,:)


    read*, h,w
    allocate(a(w,h))
    allocate(ax1(w*h), ay1(w*h), ax2(w*h), ay2(w*h))
    allocate(pass(0:w+1,0:h+1), source=.false.)
    pass(:,0) = .true.
    pass(:,h+1) = .true.
    pass(0,:) = .true.
    pass(w+1,:) = .true.

    do i=1,h
        read*, a(:,i)
    end do

    x=1; y=1; d=0

    do while(.true.)
        pass(x,y) = .true.
        if(.not. next_xy(x,y,d,nx,ny)) exit
        if (mod(a(x,y),2) == 1) then
            ans=ans+1
            ax1(ans)=x; ay1(ans)=y; ax2(ans)=nx; ay2(ans)=ny
            a(x,y)=a(x,y)-1
            a(nx,ny)=a(nx,ny)+1
        end if
        x=nx; y=ny
    end do
    print'(i0)', ans
    do i=1,ans
        print'(*(i0,1x))', ay1(i), ax1(i), ay2(i), ax2(i)
    end do

contains
    function next_xy(x,y,d,nx,ny) result(ret)
        integer(int32),intent(in):: x,y
        integer(int32),intent(out):: nx,ny
        integer(int32),intent(inout):: d
        integer(int32):: dx(0:3) = [1,0,-1,0]
        integer(int32):: dy(0:3) = [0,1,0,-1]
        integer(int32):: nd
        logical:: ret
        ret = .true.
        nd = d
        nx = x+dx(nd); ny = y+dy(nd)
        do while(pass(nx,ny))
            nd=mod(nd+1,4)
            nx=x+dx(nd); ny=y+dy(nd)
            if (nd == d) then
                ret = .false.
                return
            end if
        end do
    end function
end program main