#include <bits/stdc++.h>
     
using namespace std;
 
vector <int> v[501];
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
vector <pair<int,int>> p;
bool isdir[501];
int res[250010][4];

int main(void)
{
    int h, w, t;
    
 
    scanf("%d %d",&h,&w);
 
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            scanf("%d",&t);
            if (t % 2 == 1)
            {
                v[i].push_back(j);
            }
        }
    }
 
    bool flag = true;
    for(int i=1;i<=h;i++)
    {
        if(v[i].size()>0)
        {
            isdir[i] = flag;
            if(flag)
            {
                for(int j=0;j<v[i].size();j++)
                {
                    p.push_back(make_pair(i,v[i][j]));
                }
                flag = false;
            }
            else
            {
                for(int j=v[i].size()-1;j>=0;j--)
                {
                    p.push_back(make_pair(i,v[i][j]));
                }
                flag = true;
            }
        }
    }
    
    int num = 0;
    for(int i=0;i<p.size();i+=2)
    {
        if(i+1>=p.size())
        {
            continue;
        }
        int sy = p[i].first;
        int sx = p[i].second;
        int gy = p[i+1].first;
        int gx = p[i+1].second;
        //cout << sy << ' ' << sx << ' ' << gy << ' ' << gx << '\n';
        if(sy!=gy)
        {
            if(isdir[sy]==true)
            {
                while(sx!=w)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx + 1;
                    num++;
                    //res.push_back({sy,sx,sy,sx+1});
                    sx+=1;
                }
                while(sy!=gy)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy+1;
                    res[num][3] = sx;
                    num++;
                    //res.push_back({sy,sx,sy+1,sx});
                    sy+=1;
                }
                while(sx!=gx)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx - 1;
                    num++;
                    //res.push_back({sy,sx,sy,sx-1});
                    sx-=1;
                }
            }
            else
            {
                while(sx>1)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx - 1;
                    num++;
                    sx-=1;
                }
                while(sy!=gy)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy+1;
                    res[num][3] = sx;
                    num++;
                    sy+=1;
                }
                while(sx!=gx)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx + 1;
                    num++;
                    sx+=1;
                }
            }
        }
        else
        {
            if(sx<gx)
            {
                while(sx!=gx)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx + 1;
                    num++;
                    sx+=1;
                }
            }
            else
            {
                while(sx!=gx)
                {
                    res[num][0] = sy;
                    res[num][1] = sx;
                    res[num][2] = sy;
                    res[num][3] = sx - 1;
                    num++;
                    sx-=1;
                }
            }
        }
    }
 
    
    
    printf("%d\n",num);
 
    for(int i=0;i<num;i++)
    {
        printf("%d %d %d %d\n",res[i][0],res[i][1],res[i][2],res[i][3]);
        //cout << res[i][0] << ' ' << res[i][1] << ' ' << res[i][2] << ' ' << res[i][3] << '\n';
    }
 
    return 0;
}

Measured memory_bytes: 7152