#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define putchar putchar_unlocked
#define Would
#define you
#define please

const int cm = 1 << 19;
char cn[cm], *ci = cn, ct;

inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], *di = dn, dt;
char n[501] = { 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 };
char c[2004] = { 48,0,0,1,49,0,0,1,50,0,0,1,51,0,0,1,52,0,0,1,53,0,0,1,54,0,0,1,55,0,0,1,56,0,0,1,57,0,0,2,49,48,0,2,49,49,0,2,49,50,0,2,49,51,0,2,49,52,0,2,49,53,0,2,49,54,0,2,49,55,0,2,49,56,0,2,49,57,0,2,50,48,0,2,50,49,0,2,50,50,0,2,50,51,0,2,50,52,0,2,50,53,0,2,50,54,0,2,50,55,0,2,50,56,0,2,50,57,0,2,51,48,0,2,51,49,0,2,51,50,0,2,51,51,0,2,51,52,0,2,51,53,0,2,51,54,0,2,51,55,0,2,51,56,0,2,51,57,0,2,52,48,0,2,52,49,0,2,52,50,0,2,52,51,0,2,52,52,0,2,52,53,0,2,52,54,0,2,52,55,0,2,52,56,0,2,52,57,0,2,53,48,0,2,53,49,0,2,53,50,0,2,53,51,0,2,53,52,0,2,53,53,0,2,53,54,0,2,53,55,0,2,53,56,0,2,53,57,0,2,54,48,0,2,54,49,0,2,54,50,0,2,54,51,0,2,54,52,0,2,54,53,0,2,54,54,0,2,54,55,0,2,54,56,0,2,54,57,0,2,55,48,0,2,55,49,0,2,55,50,0,2,55,51,0,2,55,52,0,2,55,53,0,2,55,54,0,2,55,55,0,2,55,56,0,2,55,57,0,2,56,48,0,2,56,49,0,2,56,50,0,2,56,51,0,2,56,52,0,2,56,53,0,2,56,54,0,2,56,55,0,2,56,56,0,2,56,57,0,2,57,48,0,2,57,49,0,2,57,50,0,2,57,51,0,2,57,52,0,2,57,53,0,2,57,54,0,2,57,55,0,2,57,56,0,2,57,57,0,3,49,48,48,3,49,48,49,3,49,48,50,3,49,48,51,3,49,48,52,3,49,48,53,3,49,48,54,3,49,48,55,3,49,48,56,3,49,48,57,3,49,49,48,3,49,49,49,3,49,49,50,3,49,49,51,3,49,49,52,3,49,49,53,3,49,49,54,3,49,49,55,3,49,49,56,3,49,49,57,3,49,50,48,3,49,50,49,3,49,50,50,3,49,50,51,3,49,50,52,3,49,50,53,3,49,50,54,3,49,50,55,3,49,50,56,3,49,50,57,3,49,51,48,3,49,51,49,3,49,51,50,3,49,51,51,3,49,51,52,3,49,51,53,3,49,51,54,3,49,51,55,3,49,51,56,3,49,51,57,3,49,52,48,3,49,52,49,3,49,52,50,3,49,52,51,3,49,52,52,3,49,52,53,3,49,52,54,3,49,52,55,3,49,52,56,3,49,52,57,3,49,53,48,3,49,53,49,3,49,53,50,3,49,53,51,3,49,53,52,3,49,53,53,3,49,53,54,3,49,53,55,3,49,53,56,3,49,53,57,3,49,54,48,3,49,54,49,3,49,54,50,3,49,54,51,3,49,54,52,3,49,54,53,3,49,54,54,3,49,54,55,3,49,54,56,3,49,54,57,3,49,55,48,3,49,55,49,3,49,55,50,3,49,55,51,3,49,55,52,3,49,55,53,3,49,55,54,3,49,55,55,3,49,55,56,3,49,55,57,3,49,56,48,3,49,56,49,3,49,56,50,3,49,56,51,3,49,56,52,3,49,56,53,3,49,56,54,3,49,56,55,3,49,56,56,3,49,56,57,3,49,57,48,3,49,57,49,3,49,57,50,3,49,57,51,3,49,57,52,3,49,57,53,3,49,57,54,3,49,57,55,3,49,57,56,3,49,57,57,3,50,48,48,3,50,48,49,3,50,48,50,3,50,48,51,3,50,48,52,3,50,48,53,3,50,48,54,3,50,48,55,3,50,48,56,3,50,48,57,3,50,49,48,3,50,49,49,3,50,49,50,3,50,49,51,3,50,49,52,3,50,49,53,3,50,49,54,3,50,49,55,3,50,49,56,3,50,49,57,3,50,50,48,3,50,50,49,3,50,50,50,3,50,50,51,3,50,50,52,3,50,50,53,3,50,50,54,3,50,50,55,3,50,50,56,3,50,50,57,3,50,51,48,3,50,51,49,3,50,51,50,3,50,51,51,3,50,51,52,3,50,51,53,3,50,51,54,3,50,51,55,3,50,51,56,3,50,51,57,3,50,52,48,3,50,52,49,3,50,52,50,3,50,52,51,3,50,52,52,3,50,52,53,3,50,52,54,3,50,52,55,3,50,52,56,3,50,52,57,3,50,53,48,3,50,53,49,3,50,53,50,3,50,53,51,3,50,53,52,3,50,53,53,3,50,53,54,3,50,53,55,3,50,53,56,3,50,53,57,3,50,54,48,3,50,54,49,3,50,54,50,3,50,54,51,3,50,54,52,3,50,54,53,3,50,54,54,3,50,54,55,3,50,54,56,3,50,54,57,3,50,55,48,3,50,55,49,3,50,55,50,3,50,55,51,3,50,55,52,3,50,55,53,3,50,55,54,3,50,55,55,3,50,55,56,3,50,55,57,3,50,56,48,3,50,56,49,3,50,56,50,3,50,56,51,3,50,56,52,3,50,56,53,3,50,56,54,3,50,56,55,3,50,56,56,3,50,56,57,3,50,57,48,3,50,57,49,3,50,57,50,3,50,57,51,3,50,57,52,3,50,57,53,3,50,57,54,3,50,57,55,3,50,57,56,3,50,57,57,3,51,48,48,3,51,48,49,3,51,48,50,3,51,48,51,3,51,48,52,3,51,48,53,3,51,48,54,3,51,48,55,3,51,48,56,3,51,48,57,3,51,49,48,3,51,49,49,3,51,49,50,3,51,49,51,3,51,49,52,3,51,49,53,3,51,49,54,3,51,49,55,3,51,49,56,3,51,49,57,3,51,50,48,3,51,50,49,3,51,50,50,3,51,50,51,3,51,50,52,3,51,50,53,3,51,50,54,3,51,50,55,3,51,50,56,3,51,50,57,3,51,51,48,3,51,51,49,3,51,51,50,3,51,51,51,3,51,51,52,3,51,51,53,3,51,51,54,3,51,51,55,3,51,51,56,3,51,51,57,3,51,52,48,3,51,52,49,3,51,52,50,3,51,52,51,3,51,52,52,3,51,52,53,3,51,52,54,3,51,52,55,3,51,52,56,3,51,52,57,3,51,53,48,3,51,53,49,3,51,53,50,3,51,53,51,3,51,53,52,3,51,53,53,3,51,53,54,3,51,53,55,3,51,53,56,3,51,53,57,3,51,54,48,3,51,54,49,3,51,54,50,3,51,54,51,3,51,54,52,3,51,54,53,3,51,54,54,3,51,54,55,3,51,54,56,3,51,54,57,3,51,55,48,3,51,55,49,3,51,55,50,3,51,55,51,3,51,55,52,3,51,55,53,3,51,55,54,3,51,55,55,3,51,55,56,3,51,55,57,3,51,56,48,3,51,56,49,3,51,56,50,3,51,56,51,3,51,56,52,3,51,56,53,3,51,56,54,3,51,56,55,3,51,56,56,3,51,56,57,3,51,57,48,3,51,57,49,3,51,57,50,3,51,57,51,3,51,57,52,3,51,57,53,3,51,57,54,3,51,57,55,3,51,57,56,3,51,57,57,3,52,48,48,3,52,48,49,3,52,48,50,3,52,48,51,3,52,48,52,3,52,48,53,3,52,48,54,3,52,48,55,3,52,48,56,3,52,48,57,3,52,49,48,3,52,49,49,3,52,49,50,3,52,49,51,3,52,49,52,3,52,49,53,3,52,49,54,3,52,49,55,3,52,49,56,3,52,49,57,3,52,50,48,3,52,50,49,3,52,50,50,3,52,50,51,3,52,50,52,3,52,50,53,3,52,50,54,3,52,50,55,3,52,50,56,3,52,50,57,3,52,51,48,3,52,51,49,3,52,51,50,3,52,51,51,3,52,51,52,3,52,51,53,3,52,51,54,3,52,51,55,3,52,51,56,3,52,51,57,3,52,52,48,3,52,52,49,3,52,52,50,3,52,52,51,3,52,52,52,3,52,52,53,3,52,52,54,3,52,52,55,3,52,52,56,3,52,52,57,3,52,53,48,3,52,53,49,3,52,53,50,3,52,53,51,3,52,53,52,3,52,53,53,3,52,53,54,3,52,53,55,3,52,53,56,3,52,53,57,3,52,54,48,3,52,54,49,3,52,54,50,3,52,54,51,3,52,54,52,3,52,54,53,3,52,54,54,3,52,54,55,3,52,54,56,3,52,54,57,3,52,55,48,3,52,55,49,3,52,55,50,3,52,55,51,3,52,55,52,3,52,55,53,3,52,55,54,3,52,55,55,3,52,55,56,3,52,55,57,3,52,56,48,3,52,56,49,3,52,56,50,3,52,56,51,3,52,56,52,3,52,56,53,3,52,56,54,3,52,56,55,3,52,56,56,3,52,56,57,3,52,57,48,3,52,57,49,3,52,57,50,3,52,57,51,3,52,57,52,3,52,57,53,3,52,57,54,3,52,57,55,3,52,57,56,3,52,57,57,3,53,48,48 };
inline void putints(int X) {
	auto N = *(n + X);
	memcpy(di, c + (X << 2), N);
	di += N;
	*di++ = ' ';
}
inline void putint(int X) {
	auto N = *(n + X);
	memcpy(di, c + (X << 2), N);
	di += N;
	*di++ = '\n';
}

inline void putk(int X) {
	if (X == 0) putchar('0');
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));
	putchar('\n');
}

int main() {
	fread(cn, 1, cm, stdin);
	ci = cn;

	int H, W;
	bool a = 0, b = 0;
	H = getint();
	W = getint();
	int k = 0;
	rep1(i, H) {
		rep1(ii, W - 1) {
			a ^= *ci & 1;
			ci += 2;
			if (a) {
				k++;
				putints(i);
				putints(ii);
				putints(i);
				putint(ii + 1);
			}
		}
		if (i != H) {
			b ^= a ^ (*ci & 1);
			ci += 2;
			if (b) {
				k++;
				putints(i);
				putints(W);
				putints(i + 1);
				putint(W);
			}
		}
		a = false;
	}

	putk(k);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4480