#include <bits/stdc++.h>
using namespace std;
const int maxn = 310;
struct mes {
  int x, y, u, v;
};
int n, m;
deque<bool> a[maxn][maxn], b[maxn][maxn], tmp;
int sum[maxn][maxn][2], cnt[maxn][maxn];
int row[maxn][2];
vector<mes> ans;
void readst(deque<bool> &cur, int x, int y, bool flag) {
  char ch;
  while ((ch = getchar()) != '0' && ch != '1')
    ;
  cur.push_back(ch == '1');
  sum[x][y][(ch == '1')] += flag;
  while ((ch = getchar()) == '0' || ch == '1') {
    cur.push_back(ch == '1');
    sum[x][y][(ch == '1')] += flag;
  }
}
void read() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) readst(a[i][j], i, j, false);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) readst(b[i][j], i, j, true);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      for (int k = 0; k < 2; ++k) row[i][k] += sum[i][j][k];
}
void print() {
  for (int i = 1; i <= n; ++i, putchar('\n'))
    for (int j = 1; j <= m; ++j) {
      tmp = a[i][j];
      while (!tmp.empty()) {
        printf("%d", tmp.front());
        tmp.pop_front();
      }
      putchar(' ');
    }
  puts("");
}
void mov(int x, int y, int u, int v) {
  ans.push_back(mes{x, y, u, v});
  a[u][v].push_front(a[x][y].back());
  a[x][y].pop_back();
  ++cnt[u][v];
}
void solve() {
  for (int i = 1; i <= n; ++i)
    for (int j = 2; j < m; ++j) {
      while (!a[i][j].empty())
        if (a[i][j].back())
          mov(i, j, i, m);
        else
          mov(i, j, i, 1);
    }
  while (a[1][1].size() > cnt[1][1])
    if (a[1][1].back())
      mov(1, 1, 1, m);
    else
      mov(1, 1, 2, 1);
  while (a[1][m].size() > cnt[1][m])
    if (a[1][m].back())
      mov(1, m, 2, m);
    else
      mov(1, m, 1, 1);
  for (int i = 2; i <= n; ++i) {
    while (!a[i][1].empty())
      if (a[i][1].back())
        mov(i, 1, i, m);
      else
        mov(i, 1, 1, 1);
    while (!a[i][m].empty())
      if (a[i][m].back())
        mov(i, m, 1, m);
      else {
        mov(i, m, i, 1);
        mov(i, 1, 1, 1);
      }
  }
  while (!b[1][1].empty()) {
    if (b[1][1].back())
      mov(1, m, 1, 1);
    else {
      mov(1, 1, 2, 1);
      mov(2, 1, 1, 1);
    }
    b[1][1].pop_back();
  }
  while (!b[1][m].empty()) {
    if (b[1][m].back()) {
      mov(1, m, 2, m);
      mov(2, m, 1, m);
    } else
      mov(1, 1, 1, m);
    b[1][m].pop_back();
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = row[i][0] - sum[i][1][0]; j > 0; --j) mov(1, 1, i, 1);
    while (!b[i][1].empty()) {
      if (b[i][1].back()) {
        mov(1, m, i, m);
        mov(i, m, i, 1);
      } else
        mov(1, 1, i, 1);
      b[i][1].pop_back();
    }
    for (int j = row[i][1] - sum[i][m][1] - sum[i][1][1]; j > 0; --j)
      mov(1, m, i, m);
    while (!b[i][m].empty()) {
      if (b[i][m].back())
        mov(1, m, i, m);
      else
        mov(i, 1, i, m);
      b[i][m].pop_back();
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 2; j < m; ++j)
      while (!b[i][j].empty()) {
        if (b[i][j].back())
          mov(i, m, i, j);
        else
          mov(i, 1, i, j);
        b[i][j].pop_back();
      }
  printf("%d\n", ans.size());
  for (auto &i : ans) printf("%d %d %d %d\n", i.x, i.y, i.u, i.v);
}
int main() {
  read();
  solve();
  return 0;
}
