#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 312;
const long long inf = 2e9;
int n, m, zero, one;
string s[N][N], t[N][N];
vector<pair<pair<int, int>, pair<int, int> > > res;
inline void move(int xa, int ya, int xb, int yb) {
  res.push_back({{xa, ya}, {xb, yb}});
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= m; ++j) {
      cin >> s[i][j];
      for (int k = 0; k < s[i][j].length(); ++k)
        if (s[i][j][k] == '0')
          ++zero;
        else
          ++one;
    }
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= m; ++j) cin >> t[i][j];
  for (int i = 1; i <= n; ++i) {
    for (int j = m; j >= 1; --j) {
      if (i == 1 && j == 1 || i == n && j == m) continue;
      for (int k = int(s[i][j].length()) - 1; k >= 0; --k) {
        char x = s[i][j][k];
        if (x == '0') {
          if (i == 1 || j == 1) {
            move(i, j, 1, 1);
          } else {
            move(i, j, 1, j);
            move(1, j, 1, 1);
          }
        } else {
          if (i == n || j == m) {
            move(i, j, n, m);
          } else {
            move(i, j, i, m);
            move(i, m, n, m);
          }
        }
      }
    }
  }
  for (int k = int(s[1][1].length()) - 1; k >= 0; --k) {
    char x = s[1][1][k];
    if (x == '0') {
      move(1, 1, 1, m);
      move(1, m, 1, 1);
    } else {
      move(1, 1, 1, m);
      move(1, m, n, m);
    }
  }
  for (int k = int(s[n][m].length()) - 1; k >= 0; --k) {
    char x = s[n][m][k];
    if (x == '0') {
      move(n, m, 1, m);
      move(1, m, 1, 1);
    } else {
      move(n, m, 1, m);
      move(1, m, n, m);
    }
  }
  for (int k = int(t[1][1].length()) - 1; k >= 0; --k) {
    char x = t[1][1][k];
    if (x == '0') {
      move(1, 1, 1, m);
      move(1, m, 1, 1);
    } else {
      move(n, m, 1, m);
      move(1, m, 1, 1);
    }
  }
  for (int k = int(t[n][m].length()) - 1; k >= 0; --k) {
    char x = t[n][m][k];
    if (x == '0') {
      move(1, 1, 1, m);
      move(1, m, n, m);
    } else {
      move(n, m, 1, m);
      move(1, m, n, m);
    }
  }
  for (int i = n; i >= 1; --i)
    for (int j = 1; j <= m; ++j) {
      if (i == 1 && j == 1 || i == n && j == m) continue;
      for (int k = int(t[i][j].length()) - 1; k >= 0; --k) {
        char x = t[i][j][k];
        if (x == '0') {
          if (i == 1 || j == 1) {
            move(1, 1, i, j);
          } else {
            move(1, 1, 1, j);
            move(1, j, i, j);
          }
        } else {
          if (i == n || j == m) {
            move(n, m, i, j);
          } else {
            move(n, m, i, m);
            move(i, m, i, j);
          }
        }
      }
    }
  cout << res.size() << '\n';
  for (auto &x : res) {
    cout << x.first.first << ' ' << x.first.second << ' ' << x.second.first
         << ' ' << x.second.second << '\n';
  }
  return 0;
}
