#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a), i##_len = (b); i < i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _repr(i, n) repri(i, n, 0)
#define repri(i, a, b) for(int i = int(a), i##_len = (b); i >= i##_len; --i)
/* 閉区間で定義しているので注意！repr(i,n,m)でn〜mまで */
#define repr(...) _overload3(__VA_ARGS__, repri, _repr, )(__VA_ARGS__)
/* 逆回しのループ。両閉区間であることに注意 */
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
#define int lint
const int INF = (int)1145141919;
int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = (lint)1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << " " << p.second;
    return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for(int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? ", " : "");
    }
    os << "]";
    return os;
}

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
    for(T &in : v)
        is >> in;
    return is;
}

template <typename T = lint> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for(auto &e : t)
        fill_v(e, v);
}

auto move(int H, int W, int i, int j) {
    int x, y;
    if((j == W - 1 && i % 2 == 0) || (j == 0 && i % 2 == 1)) {
        if((H % 2 == 1 && i == H - 1 && j == W - 1) ||
           (H % 2 == 0 && j == 0 && i == H - 1)) {
            return pair<int, int>(0, 0);
        }
        y = 0;
        x = 1;
    } else {
        y = pow(-1, i);
        x = 0;
    }
    return pair<int, int>(x, y);
}

signed main() {
#ifdef LOCAL
    // ifstream in("in_1.txt");
    // cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif

    /* input part */
    int H, W;
    cin >> H >> W;
    auto a = make_v<int>(H, W);
    cin >> a;
    int x = 0, y = 0;
    auto suba = a;
    int cnt = 0;
    while(move(H, W, x, y) != pair<int, int>(0, 0)) {
        bool flag = false;
        if(suba[x][y] % 2 == 1) {
            suba[x][y]--;
            flag = true;
            cnt++;
        }
        auto p = move(H, W, x, y);
        x += p.first;
        y += p.second;
        if(flag) {
            suba[x][y]++;
        }
        // cout << x << " " << y << endl;
    }
    cout << cnt << endl;
    x = 0;
    y = 0;
    while(move(H, W, x, y) != pair<int, int>(0, 0)) {
        bool flag = false;
        if(a[x][y] % 2 == 1) {
            a[x][y]--;
            flag = true;
            cout << x + 1 << " " << y + 1;
        }
        auto p = move(H, W, x, y);
        x += p.first;
        y += p.second;
        if(flag) {
            a[x][y]++;
            cout << " " << x + 1 << " " << y + 1 << endl;
        }
        // cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 6016