#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[2][305][305], Cnt[2][305][305];
string st[305][305], ed[305][305];
int l[305][305], L[305][305];
pair<pair<int, int>, pair<int, int> > ans1[400005], ans2[400005];
int tot1, tot2;
void mv1(int x, int y, int xx, int yy, int val) {
  cnt[val][x][y]--, cnt[val][xx][yy]++;
  ans1[++tot1] = make_pair(make_pair(x, y), make_pair(xx, yy));
}
void mv2(int x, int y, int xx, int yy, int val) {
  Cnt[val][x][y]--, Cnt[val][xx][yy]++;
  ans2[++tot2] = make_pair(make_pair(xx, yy), make_pair(x, y));
}
void work2() {
  tot1 = tot2 = 0;
  for (int i = 1; i <= n; i++) {
    int nxt = i % n + 1, q0q = 0, q1q = 0;
    for (int k = l[i][1] - 1; k >= 0; k--)
      if (st[i][1][k] == '0')
        mv1(i, 1, nxt, 1, 0), q0q++;
      else
        mv1(i, 1, i, m, 1);
    for (int k = l[i][m] - 1; k >= 0; k--)
      if (st[i][m][k] == '0')
        mv1(i, m, i, 1, 0);
      else
        mv1(i, m, nxt, m, 1), q1q++;
    for (int j = 2; j < m; j++)
      for (int k = l[i][j] - 1; k >= 0; k--)
        if (st[i][j][k] == '0')
          mv1(i, j, i, 1, 0);
        else
          mv1(i, j, i, m, 1);
  }
  for (int i = 1; i <= n; i++) {
    int nxt = i % n + 1, q0q = 0, q1q = 0;
    for (int k = 0; k < L[i][1]; k++)
      if (ed[i][1][k] == '0')
        mv2(i, 1, nxt, 1, 0), q0q++;
      else
        mv2(i, 1, i, m, 1);
    for (int k = 0; k < L[i][m]; k++)
      if (ed[i][m][k] == '0')
        mv2(i, m, i, 1, 0);
      else
        mv2(i, m, nxt, m, 1), q1q++;
    for (int j = 2; j < m; j++)
      for (int k = 0; k < L[i][j]; k++)
        if (ed[i][j][k] == '0')
          mv2(i, j, i, 1, 0);
        else
          mv2(i, j, i, m, 1);
  }
  int les = 1, mor = 1;
  while (les <= n && mor <= n) {
    while (cnt[0][les][1] >= Cnt[0][les][1] && les <= n) les++;
    while (cnt[0][mor][1] <= Cnt[0][mor][1] && mor <= n) mor++;
    if (les <= n && mor <= n) mv1(mor, 1, les, 1, 0);
  }
  les = 1, mor = 1;
  while (les <= n && mor <= n) {
    while (cnt[1][les][m] >= Cnt[1][les][m] && les <= n) les++;
    while (cnt[1][mor][m] <= Cnt[1][mor][m] && mor <= n) mor++;
    if (les <= n && mor <= n) mv1(mor, m, les, m, 1);
  }
  printf("%d\n", tot1 + tot2);
  for (int i = 1; i <= tot1; i++)
    printf("%d %d %d %d\n", ans1[i].first.first, ans1[i].first.second,
           ans1[i].second.first, ans1[i].second.second);
  for (int i = tot2; i >= 1; i--)
    printf("%d %d %d %d\n", ans2[i].first.first, ans2[i].first.second,
           ans2[i].second.first, ans2[i].second.second);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> st[i][j];
      l[i][j] = st[i][j].size();
      for (int k = 0; k < l[i][j]; k++)
        if (st[i][j][k] == '0')
          cnt[0][i][j]++;
        else
          cnt[1][i][j]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> ed[i][j];
      L[i][j] = ed[i][j].size();
      for (int k = 0; k < L[i][j]; k++)
        if (ed[i][j][k] == '0')
          Cnt[0][i][j]++;
        else
          Cnt[1][i][j]++;
    }
  work2();
  return 0;
}
