#include <bits/stdc++.h>
using namespace std;
int n, m;
string a[555][555];
int g[555][555];
vector<pair<pair<int, int>, pair<int, int> > > work(bool r) {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      g[i][j] = 0;
      if (r) reverse(a[i][j].begin(), a[i][j].end());
    }
  vector<pair<pair<int, int>, pair<int, int> > > vp;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      for (int s = int(a[i][j].size()) - 1; ~s; --s) {
        if (a[i][j][s] == '0') {
          if (i != 1)
            vp.push_back(make_pair(pair<int, int>(i, j), pair<int, int>(1, j))),
                ++g[1][j];
          else
            vp.push_back(make_pair(pair<int, int>(i, j),
                                   pair<int, int>(1, (j == 1) ? 2 : 1))),
                ++g[1][(j == 1) ? 2 : 1];
        } else {
          if (i != n)
            vp.push_back(make_pair(pair<int, int>(i, j), pair<int, int>(n, j))),
                ++g[n][j];
          else
            vp.push_back(make_pair(pair<int, int>(i, j),
                                   pair<int, int>(n, (j == 1) ? 2 : 1))),
                ++g[n][(j == 1) ? 2 : 1];
        }
      }
    }
  for (int i = 1; i <= n; i += n - 1)
    for (int j = 2; j <= m; ++j)
      for (int t = 0; t < g[i][j]; ++t)
        vp.push_back(make_pair(pair<int, int>(i, j), pair<int, int>(i, 1)));
  return vp;
}
int main() {
  cin >> n >> m;
  auto w = work(0);
  auto g = work(1);
  reverse(g.begin(), g.end());
  for (auto t : g) w.push_back(make_pair(t.second, t.first));
  printf("%d\n", int(w.size()));
  for (auto t : w)
    printf("%d %d %d %d\n", t.first.first, t.first.second, t.second.first,
           t.second.second);
}
