#include <bits/stdc++.h>
using namespace std;
const int N = 305;
const int M = 400005;
int read() {
  int x = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * flag;
}
int n, m, tot, t, cnt[N][N], ans[M][4];
string s;
void ins(int x1, int y1, int x2, int y2) {
  cnt[x2][y2]++;
  ans[++tot][0] = x1;
  ans[tot][1] = y1;
  ans[tot][2] = x2;
  ans[tot][3] = y2;
}
void add(int x, int y, int f) {
  if (f) {
    if (x != 1)
      ins(x, y, 1, y);
    else
      ins(x, y, 1, y == 1 ? 2 : 1);
    return;
  }
  if (x != 2)
    ins(x, y, 2, y);
  else
    ins(x, y, 2, y == 1 ? 2 : 1);
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> s;
      for (int k = s.size() - 1; k >= 0; k--) add(i, j, s[k] == '1');
    }
  for (int i = 1; i <= 2; i++)
    for (int j = 2; j <= m; j++)
      for (int k = 1; k <= cnt[i][j]; k++) ins(i, j, i, 1);
  t = tot;
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> s;
      for (int k = 0; k < s.size(); k++) add(i, j, s[k] == '1');
    }
  for (int i = 1; i <= 2; i++)
    for (int j = 2; j <= m; j++)
      for (int k = 1; k <= cnt[i][j]; k++) ins(i, j, i, 1);
  printf("%d\n", tot);
  for (int i = 1; i <= t; i++)
    printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
  for (int i = tot; i > t; i--)
    printf("%d %d %d %d\n", ans[i][2], ans[i][3], ans[i][0], ans[i][1]);
}
