#include <bits/stdc++.h>
using namespace std;
int i, j, k, z, q, timer, x, y, n, m, cnt, even, flag, dlfjl, dskgj, dkfj,
    dskfj, boom, r, c;
string expected[305][305];
deque<char> cur[305][305];
int cursz[305][305];
vector<pair<int, int> > shits[2], toshits[2];
int pnt[2];
vector<pair<pair<int, int>, pair<int, int> > > ans;
void Move(int dlfjl, int dskgj, int dkfj, int dskfj, int p = -1) {
  if (p != -1) {
    shits[p].push_back(make_pair(dkfj, dskfj));
  }
  char c = cur[dlfjl][dskgj].back();
  cur[dlfjl][dskgj].pop_back();
  cur[dkfj][dskfj].push_front(c);
  dlfjl++;
  dskgj++;
  dkfj++;
  dskfj++;
  ans.push_back(make_pair(make_pair(dlfjl, dskgj), make_pair(dkfj, dskfj)));
}
void move_inside(int dlfjl, int dskgj, int dkfj, int dskfj) {
  if (dlfjl == dkfj && dskgj == dskfj) return;
  if (dlfjl == dkfj || dskgj == dskfj) {
    Move(dlfjl, dskgj, dkfj, dskfj);
    return;
  }
  Move(dlfjl, dskgj, dkfj, dskgj);
  Move(dkfj, dskgj, dkfj, dskfj);
}
void Prepare(int i, int j, int val) {
  if (val == 0) {
    if (i < n / 2) {
      if (j > 0)
        toshits[0].push_back(make_pair(i, j - 1));
      else
        toshits[0].push_back(make_pair(i, j + 1));
    } else {
      toshits[0].push_back(make_pair(0, j));
    }
  } else {
    if (i >= n / 2) {
      if (j > 0)
        toshits[1].push_back(make_pair(i, j - 1));
      else
        toshits[1].push_back(make_pair(i, j + 1));
    } else {
      toshits[1].push_back(make_pair(n - 1, j));
    }
  }
}
void MoveTo(int i, int j, int val) {
  if (val == 0) {
    if (i < n / 2) {
      if (j > 0)
        Move(i, j - 1, i, j);
      else
        Move(i, j + 1, i, j);
    } else {
      Move(0, j, i, j);
    }
  } else {
    if (i >= n / 2) {
      if (j > 0)
        Move(i, j - 1, i, j);
      else
        Move(i, j + 1, i, j);
    } else {
      Move(n - 1, j, i, j);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      string s;
      cin >> s;
      for (int k = 0; k < s.size(); k++) cur[i][j].push_back(s[k]);
      cursz[i][j] = s.size();
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> expected[i][j];
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < cursz[i][j]; k++) {
        if (cur[i][j].back() == '0') {
          if (i < n / 2) {
            if (j > 0)
              Move(i, j, i, j - 1, 0);
            else
              Move(i, j, i, j + 1, 0);
          } else {
            Move(i, j, 0, j, 0);
          }
        } else {
          if (i >= n / 2) {
            if (j > 0)
              Move(i, j, i, j - 1, 1);
            else
              Move(i, j, i, j + 1, 1);
          } else {
            Move(i, j, n - 1, j, 1);
          }
        }
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int sz = expected[i][j].size();
      for (int k = sz - 1; k >= 0; k--) {
        Prepare(i, j, (int)(expected[i][j][k] - '0'));
      }
    }
  for (int p = 0; p < 2; p++)
    for (int j = 0; j < shits[p].size(); j++) {
      move_inside(shits[p][j].first, shits[p][j].second, toshits[p][j].first,
                  toshits[p][j].second);
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int sz = expected[i][j].size();
      for (int k = sz - 1; k >= 0; k--) {
        MoveTo(i, j, (int)(expected[i][j][k] - '0'));
      }
    }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d %d %d\n", ans[i].first.first, ans[i].first.second,
           ans[i].second.first, ans[i].second.second);
  }
  return 0;
}
