#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int N = 307;
int n, m;
struct oper {
  int ia, ja, ib, jb;
  oper(int ia, int ja, int ib, int jb) : ia(ia), ja(ja), ib(ib), jb(jb) {}
};
struct mac {
  string s[N][N];
  int poz[N][N];
  vector<oper> wyn;
  void wczytaj(bool odwr) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        cin >> s[i][j];
        if (odwr) reverse(s[i][j].begin(), s[i][j].end());
      }
    }
  }
  void rusz(int ia, int ja, int ib, int jb) {
    assert(ia != ib || ja != jb);
    assert(ia == ib || ja == jb);
    assert(poz[ia][ja] < (int)s[ia][ja].size());
    char c = s[ia][ja][poz[ia][ja]];
    poz[ia][ja]++;
    s[ib][jb].push_back(c);
    wyn.emplace_back(ia, ja, ib, jb);
  }
  bool cosJest(int i, int j) { return poz[i][j] < (int)s[i][j].size(); }
  vector<oper> res() {
    wyn.clear();
    while (cosJest(1, 1)) {
      if (s[1][1][poz[1][1]] == '0')
        rusz(1, 1, 1, m);
      else
        rusz(1, 1, n, 1);
    }
    while (cosJest(n, m)) {
      if (s[n][m][poz[n][m]] == '0')
        rusz(n, m, 1, m);
      else
        rusz(n, m, n, 1);
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (make_pair(i, j) == make_pair(1, 1) ||
            make_pair(i, j) == make_pair(n, m))
          continue;
        while (cosJest(i, j)) {
          if (s[i][j][poz[i][j]] == '0') {
            if (i != 1)
              rusz(i, j, 1, j);
            else
              rusz(i, j, 1, 1);
          } else {
            if (i != n)
              rusz(i, j, n, j);
            else
              rusz(i, j, n, m);
          }
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (make_pair(i, j) == make_pair(1, 1) ||
            make_pair(i, j) == make_pair(n, m))
          continue;
        while (cosJest(i, j)) {
          if (s[i][j][poz[i][j]] == '0') {
            assert(i == 1);
            rusz(1, j, 1, 1);
          } else {
            assert(i == n);
            rusz(n, j, n, m);
          }
        }
      }
    }
    return wyn;
  }
};
mac A, B;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  A.wczytaj(1);
  B.wczytaj(0);
  vector<oper> wyna = A.res();
  vector<oper> wynb = B.res();
  reverse(wynb.begin(), wynb.end());
  for (auto& u : wynb) {
    swap(u.ia, u.ib);
    swap(u.ja, u.jb);
  }
  wyna.insert(wyna.end(), wynb.begin(), wynb.end());
  cout << wyna.size() << endl;
  for (auto u : wyna) {
    cout << u.ia << ' ' << u.ja << ' ' << u.ib << ' ' << u.jb << '\n';
  }
  return 0;
}
