#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vec s(M), c(M);
    REP(i,0,M) {
        cin >> s[i] >> c[i];
        --s[i];
    }

    ll d = 1;
    bool f = true;
    REP(i,0,N) d *= 10;
    REP(i,N==1?0:d/10,d) {
        string S = to_string(i);
        f = true;
        REP(j,0,M) {
            if(!(s[j] < SZ(S) && S[s[j]]-'0' == c[j])) {
                f = false;
                break;
            }
        }
        if(f) {
            PR(i);
            break;
        }
    }
    if(!f) PR(-1);

    return 0;
}

/*



*/
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> board(H, vector<int>(W));
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cin >> board[h][w];
        }
    }

    vector<pair<pair<int, int>, pair<int, int>>> cmds;

    for (int h = 0; h < H; h++) {
        if (h % 2 == 0) {
            for (int w = 0; w < W; w++) {
                int next_h, next_w;
                if (w != W - 1) {
                    next_h = h;
                    next_w = w + 1;
                } else {
                    next_h = h + 1;
                    next_w = w;
                }

                if (next_h >= H) {
                    continue;
                }

                if (board[h][w] % 2 != 0) {
                    board[h][w]--;
                    board[next_h][next_w]++;
                    cmds.push_back(make_pair(make_pair(h, w), make_pair(next_h, next_w)));
                }
            }
        } else {
            for (int w = W - 1; w >= 0; w--) {
                int next_h, next_w;
                if (w != 0) {
                    next_h = h;
                    next_w = w - 1;
                } else {
                    next_h = h + 1;
                    next_w = w;
                }

                if (next_h >= H) {
                    continue;
                }

                if (board[h][w] % 2 != 0) {
                    board[h][w]--;
                    board[next_h][next_w]++;
                    cmds.push_back(make_pair(make_pair(h, w), make_pair(next_h, next_w)));
                }
            }
        }
    }

    cout << cmds.size() << endl;
    for (auto cmd : cmds) {
        pair<int, int> src = cmd.first;
        pair<int, int> dst = cmd.second;
        printf("%d %d %d %d\n", src.first + 1, src.second + 1, dst.first + 1, dst.second + 1);
    }

    return 0;
}
