#include <bits/stdc++.h>
using namespace std;
struct st {
  int a, b, c, d;
  st() {}
  st(pair<int, int> a, pair<int, int> b)
      : a(a.first), b(a.second), c(b.first), d(b.second) {}
  void pri() {
    cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << '\n';
  }
};
const int MX = 305;
int n, m;
string a[MX][MX], b[MX][MX];
pair<int, int> o[MX];
vector<st> res;
void move(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    res.emplace_back(a, pair<int, int>(b.first, a.second));
  if (a.second != b.second)
    res.emplace_back(pair<int, int>(b.first, a.second), b);
}
void move(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  if (a != b) res.emplace_back(a, b);
  if (b != c) res.emplace_back(b, c);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      reverse(a[i][j].begin(), a[i][j].end());
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> b[i][j];
      reverse(b[i][j].begin(), b[i][j].end());
    }
  o['0'] = {0, 0};
  o['1'] = {n - 1, m - 1};
  for (char h : a[0][0]) move({0, 0}, {n - 1, 0});
  a[n - 1][0] += a[0][0];
  a[0][0].clear();
  for (char h : a[n - 1][m - 1]) move({n - 1, m - 1}, {n - 1, 0});
  a[n - 1][0] += a[n - 1][m - 1];
  a[n - 1][m - 1].clear();
  for (char h : a[n - 1][0]) move({n - 1, 0}, o[h]);
  a[n - 1][0].clear();
  for (char h : a[0][m - 1]) move({0, m - 1}, o[h]);
  a[0][m - 1].clear();
  for (int i = 0; i < n; i++) {
    for (char h : a[i][0])
      if (h == '0')
        move({i, 0}, o[h]);
      else
        move({i, 0}, {n - 1, 0}, o[h]);
    for (char h : a[i][m - 1])
      if (h == '0')
        move({i, m - 1}, {0, m - 1}, o[h]);
      else
        move({i, m - 1}, o[h]);
  }
  for (int i = 0; i < m; i++) {
    for (char h : a[0][i])
      if (h == '0')
        move({0, i}, o[h]);
      else
        move({0, i}, {0, m - 1}, o[h]);
    for (char h : a[n - 1][i])
      if (h == '0')
        move({n - 1, i}, {n - 1, 0}, o[h]);
      else
        move({n - 1, i}, o[h]);
  }
  for (int i = 1; i <= n - 2; i++)
    for (int j = 1; j <= m - 2; j++)
      for (char h : a[i][j]) move({i, j}, o[h]);
  for (char h : b[0][0]) move(o[h], {n - 1, 0}, {0, 0});
  for (char h : b[n - 1][m - 1]) move(o[h], {n - 1, 0}, {n - 1, m - 1});
  for (int i = 1; i <= n - 2; i++)
    for (int j = 1; j <= m - 2; j++)
      for (char h : b[i][j]) move(o[h], {i, j});
  for (int i = 0; i < n; i++) {
    if (i && i < n - 1) {
      for (char h : b[i][0])
        if (h == '0')
          move(o[h], {i, 0});
        else
          move(o[h], {n - 1, 0}, {i, 0});
    }
    if (i && i < n - 1) {
      for (char h : b[i][m - 1])
        if (h == '0')
          move(o[h], {0, m - 1}, {i, m - 1});
        else
          move(o[h], {i, m - 1});
    }
  }
  for (int i = 0; i < m; i++) {
    if (i && i < m - 1)
      for (char h : b[0][i])
        if (h == '0')
          move(o[h], {0, i});
        else
          move(o[h], {0, m - 1}, {0, i});
    if (i && i < m - 1)
      for (char h : b[n - 1][i])
        if (h == '0')
          move(o[h], {n - 1, 0}, {n - 1, i});
        else
          move(o[h], {n - 1, i});
  }
  for (char h : b[n - 1][0]) move(o[h], {n - 1, 0});
  for (char h : b[0][m - 1]) move(o[h], {0, m - 1});
  cout << res.size() << '\n';
  for (auto r : res) r.pri();
  return 0;
}
