#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <int n, class... T>
typename enable_if<(n >= sizeof...(T))>::type _ot(ostream &,
                                                  tuple<T...> const &) {}
template <int n, class... T>
typename enable_if<(n < sizeof...(T))>::type _ot(ostream &os,
                                                 tuple<T...> const &t) {
  os << (n == 0 ? "" : ", ") << get<n>(t);
  _ot<n + 1>(os, t);
}
template <class... T>
ostream &operator<<(ostream &o, tuple<T...> const &t) {
  o << "(";
  _ot<0>(o, t);
  o << ")";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, pair<T, U> const &p) {
  o << "(" << p.first << ", " << p.second << ")";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const stack<T> &a) {
  o << "{";
  for (auto tmp = a; tmp.size(); tmp.pop())
    o << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  o << "}";
  return o;
}
template <class T,
          class = typename iterator_traits<typename T::iterator>::value_type,
          class = typename enable_if<!is_same<T, string>::value>::type>
ostream &operator<<(ostream &o, const T &a) {
  for (auto ite = a.begin(); ite != a.end(); ++ite)
    o << (ite == a.begin() ? "" : " ") << *ite;
  return o;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<tuple<int, int, int, int>> ans;
  vector<vector<string>> s(h, vector<string>(w));
  vector<vector<string>> t(h, vector<string>(w));
  vector<vector<queue<bool>>> q(h, vector<queue<bool>>(w));
  ll sum = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
      sum += s[i][j].size();
      for (int k = 0; k < s[i][j].size(); k++) {
        char c = s[i][j][s[i][j].size() - 1 - k];
        q[i][j].emplace(c - '0');
      }
      (42);
    }
  auto check = [&](int i, int j) {
    return;
    queue<bool> deb;
    deb = q[i][j];
    (42);
    while (deb.size()) (42), deb.pop();
  };
  (42);
  auto mov = [&](int i, int j, int i2, int j2) {
    ans.emplace_back(i, j, i2, j2);
    assert(q[i][j].size());
    assert(i == i2 || j == j2);
    assert(!(i == i2 && j == j2));
    auto x = q[i][j].front();
    q[i][j].pop();
    q[i2][j2].emplace(x);
  };
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) cin >> t[i][j];
  (42);
  for (int i = 2; i < h; i++) {
    for (int j = 0; j < s[i][w - 1].size(); j++) {
      if (s[i][w - 1][s[i][w - 1].size() - 1 - j] == '0') {
        if (i != 0) mov(i, w - 1, 0, w - 1);
      } else {
        if (i != 1) mov(i, w - 1, 1, w - 1);
      }
    }
  }
  (42);
  for (int i = 2; i < h; i++)
    for (int j = 0; j < w - 1; j++) {
      for (int k = 0; k < s[i][j].size(); k++) {
        int c = s[i][j][s[i][j].size() - 1 - k] - '0';
        mov(i, j, i, w - 1);
        if (c == 0) {
          mov(i, w - 1, 0, w - 1);
        } else {
          mov(i, w - 1, 1, w - 1);
        }
      }
    }
  (42);
  for (int j = 0; j < w - 1; j++) {
    while (q[0][j].size()) {
      if (q[0][j].front() == 0) {
        mov(0, j, 0, w - 1);
      } else {
        mov(0, j, 1, j);
      }
    }
  }
  (42);
  for (int j = 0; j < w - 1; j++) {
    while (q[1][j].size()) {
      if (q[1][j].front() == 1) {
        mov(1, j, 1, w - 1);
      } else {
        mov(1, j, 0, j);
      }
    }
  }
  (42);
  for (int j = 0; j < w - 1; j++) {
    while (q[0][j].size()) {
      if (q[0][j].front() == 0) {
        mov(0, j, 0, w - 1);
      } else {
        assert(0);
        mov(0, j, 1, j);
      }
    }
  }
  (42);
  for (int k = 0; k < s[0][w - 1].size(); k++) {
    if (s[0][w - 1][s[0][w - 1].size() - 1 - k] == '0') {
      mov(0, w - 1, 0, w - 2);
      mov(0, w - 2, 0, w - 1);
    } else {
      mov(0, w - 1, 1, w - 1);
    }
  }
  (42);
  for (int k = 0; k < s[1][w - 1].size(); k++) {
    if (s[1][w - 1][s[1][w - 1].size() - 1 - k] == '1') {
      mov(1, w - 1, 1, w - 2);
      mov(1, w - 2, 1, w - 1);
    } else {
      mov(1, w - 1, 0, w - 1);
    }
  }
  (42);
  for (int k = 0; k < t[0][w - 1].size(); k++) {
    if (t[0][w - 1][t[0][w - 1].size() - 1 - k] == '0') {
      mov(0, w - 1, 0, w - 2);
      mov(0, w - 2, 0, w - 1);
    } else {
      mov(1, w - 1, 0, w - 1);
    }
  }
  (42);
  for (int k = 0; k < t[1][w - 1].size(); k++) {
    if (t[1][w - 1][t[1][w - 1].size() - 1 - k] == '1') {
      mov(1, w - 1, 1, w - 2);
      mov(1, w - 2, 1, w - 1);
    } else {
      mov(0, w - 1, 1, w - 1);
    }
  }
  (42);
  for (int j = 0; j < w - 1; j++) {
    int c1 = 0;
    for (int k = 0; k < t[0][j].size(); k++) {
      int c = t[0][j][t[0][j].size() - 1 - k] - '0';
      if (c == 1) c1++, mov(1, w - 1, 1, j);
    }
    for (int k = 0; k < t[1][j].size(); k++) {
      int c = t[1][j][t[1][j].size() - 1 - k] - '0';
      if (c == 0) {
        mov(0, w - 1, 0, j);
        mov(0, j, 1, j);
      } else {
        mov(1, w - 1, 1, j);
      }
    }
    for (int k = 0; k < t[0][j].size(); k++) {
      int c = t[0][j][t[0][j].size() - 1 - k] - '0';
      if (c == 0) {
        mov(0, w - 1, 0, j);
      } else {
        mov(1, j, 0, j);
      }
    }
  }
  (42);
  for (int i = 2; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      for (int k = 0; k < t[i][j].size(); k++) {
        int c = t[i][j][t[i][j].size() - 1 - k] - '0';
        (42);
        if (c == 0) {
          if (i != 0) mov(0, w - 1, i, w - 1);
        } else {
          if (i != 1) mov(1, w - 1, i, w - 1);
        }
        mov(i, w - 1, i, j);
      }
    }
  }
  check(0, 0);
  (42);
  for (int i = 2; i < h; i++) {
    for (int k = 0; k < t[i][w - 1].size(); k++) {
      int c = t[i][w - 1][t[i][w - 1].size() - 1 - k] - '0';
      if (c == 0) {
        mov(0, w - 1, i, w - 1);
      } else {
        mov(1, w - 1, i, w - 1);
      }
    }
  }
  (42);
  cout << ans.size() << endl;
  for (auto p : ans) {
    int a, b, c, d;
    tie(a, b, c, d) = p;
    a++;
    b++;
    c++;
    d++;
    cout << a << " " << b << " " << c << " " << d << "\n";
  }
  return 0;
}
