#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
inline void solve(), read();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read();
  solve();
  return 0;
}
struct query {
  long long x1, y_1, x2, y2;
};
long long n, m;
vector<vector<deque<char>>> a, b;
inline void change(query q, vector<vector<deque<char>>>& a,
                   vector<query>& ans) {
  a[q.x2][q.y2].push_front(a[q.x1][q.y_1].back());
  a[q.x1][q.y_1].pop_back();
  ans.push_back(q);
}
void dothis(vector<vector<deque<char>>>& a, vector<query>& ans) {
  for (long long i = 1; i < n; i++) {
    for (long long k = (long long)((a[i][0]).size()) - 1; k >= 0; k--) {
      change({i, 0, 0, 0}, a, ans);
    }
  }
  for (long long j = 1; j < m; j++) {
    for (long long k = (long long)((a[0][j]).size()) - 1; k >= 0; k--) {
      change({0, j, 0, 0}, a, ans);
    }
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = 1; j < m; j++) {
      for (long long k = (long long)((a[i][j]).size()) - 1; k >= 0; k--) {
        if (a[i][j][k] == '1') {
          change({i, j, i, 0}, a, ans);
        } else {
          change({i, j, 0, j}, a, ans);
        }
      }
    }
  }
  for (long long i = 2; i < n; i++) {
    for (long long k = (long long)((a[i][0]).size()) - 1; k >= 0; k--) {
      change({i, 0, 1, 0}, a, ans);
    }
  }
  for (long long j = 2; j < m; j++) {
    for (long long k = (long long)((a[0][j]).size()) - 1; k >= 0; k--) {
      change({0, j, 0, 1}, a, ans);
    }
  }
  for (long long k = (long long)((a[0][0]).size()) - 1; k >= 0; k--) {
    if (a[0][0][k] == '1') {
      change({0, 0, 1, 0}, a, ans);
    } else {
      change({0, 0, 0, 1}, a, ans);
    }
  }
}
inline void solve() {
  vector<query> a1, a2;
  dothis(a, a1);
  dothis(b, a2);
  reverse((a2).begin(), (a2).end());
  cout << (long long)((a1).size()) + (long long)((a2).size()) << "\n";
  for (query q : a1) {
    long long x1 = q.x1, y_1 = q.y_1, x2 = q.x2, y2 = q.y2;
    cout << x1 + 1 << " " << y_1 + 1 << " " << x2 + 1 << " " << y2 + 1 << "\n";
  }
  for (query q : a2) {
    long long x1 = q.x2, y_1 = q.y2, x2 = q.x1, y2 = q.y_1;
    cout << x1 + 1 << " " << y_1 + 1 << " " << x2 + 1 << " " << y2 + 1 << "\n";
  }
}
inline void read() {
  cin >> n >> m;
  a.resize(n, vector<deque<char>>(m));
  b.resize(n, vector<deque<char>>(m));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      string s;
      cin >> s;
      a[i][j] = {(s).begin(), (s).end()};
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      string s;
      cin >> s;
      b[i][j] = {(s).begin(), (s).end()};
      reverse((b[i][j]).begin(), (b[i][j]).end());
    }
  }
}
