#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 7;
constexpr long long INFL = 1e18;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
struct Move {
  int a, b, c, d;
  Move(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
  bool iden() const { return make_pair(a, b) == make_pair(c, d); }
  void swap() { std::swap(a, c), std::swap(b, d); }
  friend ostream& operator<<(ostream& out, const Move m) {
    return out << m.a << " " << m.b << " " << m.c << " " << m.d;
  }
};
constexpr int maxn = 305;
int n, m;
string init[maxn][maxn], finish[maxn][maxn];
vector<vector<Move>> moves;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> init[i][j];
      reverse((init[i][j]).begin(), (init[i][j]).end());
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> finish[i][j];
    }
  for (auto start : {init, finish}) {
    vector<Move> ans;
    for (int i = 2; i <= n; i++) {
      for (auto c : start[i][1]) ans.emplace_back(i, 1, 1, 1);
      start[1][1] += start[i][1];
      start[i][1] = "";
    }
    for (int j = 2; j <= m; j++) {
      for (auto c : start[1][j]) ans.emplace_back(1, j, 1, 1);
      start[1][1] += start[1][j];
      start[1][j] = "";
    }
    for (int i = 2; i <= n; i++)
      for (int j = 2; j <= m; j++) {
        for (auto c : start[i][j]) {
          if (c == '0')
            ans.emplace_back(i, j, 1, j), start[1][j] += c;
          else
            ans.emplace_back(i, j, i, 1), start[i][1] += c;
        }
      }
    for (int i = 3; i <= n; i++)
      for (auto c : start[i][1]) ans.emplace_back(i, 1, 2, 1), start[2][1] += c;
    for (int i = 3; i <= m; i++)
      for (auto c : start[1][i]) ans.emplace_back(1, i, 1, 2), start[1][2] += c;
    for (auto c : start[1][1]) {
      if (c == '0')
        ans.emplace_back(1, 1, 1, 2), start[1][2] += c;
      else
        ans.emplace_back(1, 1, 2, 1), start[2][1] += c;
    }
    moves.push_back(move(ans));
  }
  reverse((moves[1]).begin(), (moves[1]).end());
  for (auto& q : moves[1]) q.swap();
  cout << moves[0].size() + moves[1].size() << "\n";
  for (auto& v : moves)
    for (auto& q : v) cout << q << "\n";
}
