#include <bits/stdc++.h>
using namespace std;
int n, m;
string s[305][305], t[305][305];
int cnt[2][305];
vector<pair<pair<int, int>, pair<int, int>>> ops;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s[i][j];
      reverse(s[i][j].begin(), s[i][j].end());
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> t[i][j];
      reverse(t[i][j].begin(), t[i][j].end());
    }
  }
  for (int i = 0; i < n; i++) {
    int nxtrow = (i + 1) % n, prvrow = (i - 1 + n) % n;
    for (char c : s[i][0]) {
      if (c == '0') {
        ops.emplace_back(make_pair(i, 0), make_pair(nxtrow, 0));
        cnt[0][nxtrow]++;
      } else {
        ops.emplace_back(make_pair(i, 0), make_pair(i, 1));
        cnt[1][i]++;
      }
    }
    for (char c : t[i][0]) {
      if (c == '0') {
        cnt[0][prvrow]--;
      } else {
        cnt[1][i]--;
      }
    }
    for (char c : s[i][1]) {
      if (c == '0') {
        ops.emplace_back(make_pair(i, 1), make_pair(i, 0));
        cnt[0][i]++;
      } else {
        ops.emplace_back(make_pair(i, 1), make_pair(nxtrow, 1));
        cnt[1][nxtrow]++;
      }
    }
    for (char c : t[i][1]) {
      if (c == '0') {
        cnt[0][i]--;
      } else {
        cnt[1][prvrow]--;
      }
    }
    for (int j = 2; j < m; j++) {
      for (char c : s[i][j]) {
        ops.emplace_back(make_pair(i, j), make_pair(i, c - '0'));
        cnt[c - '0'][i]++;
      }
      for (char c : t[i][j]) {
        cnt[c - '0'][i]--;
      }
    }
  }
  for (int i = 0; i < 2; i++) {
    int pos = 0, neg = 0;
    while (true) {
      while (pos < n && cnt[i][pos] <= 0) {
        pos++;
      }
      while (neg < n && cnt[i][neg] >= 0) {
        neg++;
      }
      if (pos == n) {
        break;
      }
      int v = min(cnt[i][pos], -cnt[i][neg]);
      cnt[i][pos] -= v;
      cnt[i][neg] += v;
      while (v--) {
        ops.emplace_back(make_pair(pos, i), make_pair(neg, i));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int prvrow = (i - 1 + n) % n;
    for (char c : t[i][0]) {
      if (c == '0') {
        ops.emplace_back(make_pair(prvrow, 0), make_pair(i, 0));
      } else {
        ops.emplace_back(make_pair(i, 1), make_pair(i, 0));
      }
    }
    for (char c : t[i][1]) {
      if (c == '0') {
        ops.emplace_back(make_pair(i, 0), make_pair(i, 1));
      } else {
        ops.emplace_back(make_pair(prvrow, 1), make_pair(i, 1));
      }
    }
    for (int j = 2; j < m; j++) {
      for (char c : t[i][j]) {
        ops.emplace_back(make_pair(i, c - '0'), make_pair(i, j));
      }
    }
  }
  cout << ops.size() << '\n';
  for (auto& op : ops) {
    cout << op.first.first + 1 << ' ' << op.first.second + 1 << ' '
         << op.second.first + 1 << ' ' << op.second.second + 1 << '\n';
  }
}
