#include <bits/stdc++.h>
using namespace std;
const int DN = 305, DM = 5e5 + 5;
int n, m, poz, cnt[2][DN], nr[2][DN], d;
string a[DN][DN], r[DN][DN], z[DN][DN];
queue<pair<pair<int, int>, pair<int, int> > > q;
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      z[i][j] = a[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> r[i][j];
      for (int h = 0; h < r[i][j].size(); h++) {
        nr[r[i][j][h] - '0'][j]++;
        if (i == 1 && r[i][j][h] == '0') {
          nr[0][j]--;
          if (j < m)
            nr[0][j + 1]++;
          else
            nr[0][j - 1]++;
        }
        if (i == n && r[i][j][h] == '1') {
          nr[1][j]--;
          if (j < m)
            nr[1][j + 1]++;
          else
            nr[1][j - 1]++;
        }
      }
    }
  for (int j = 1; j <= m; j++) {
    while (!a[1][j].empty()) {
      if (a[1][j].back() == '1') {
        cnt[1][j]++;
        a[1][j].pop_back();
        q.push({{1, j}, {n, j}});
        continue;
      }
      a[1][j].pop_back();
      if (j == m) {
        q.push({{1, j}, {1, j - 1}});
        cnt[0][j - 1]++;
      } else {
        q.push({{1, j}, {1, j + 1}});
        cnt[0][j + 1]++;
      }
    }
    while (!a[n][j].empty()) {
      if (a[n][j].back() == '0') {
        cnt[0][j]++;
        a[n][j].pop_back();
        q.push({{n, j}, {1, j}});
        continue;
      }
      a[n][j].pop_back();
      if (j == m) {
        q.push({{n, j}, {n, j - 1}});
        cnt[1][j - 1]++;
      } else {
        q.push({{n, j}, {n, j + 1}});
        cnt[1][j + 1]++;
      }
    }
    for (int i = 2; i < n; i++)
      while (!a[i][j].empty()) {
        if (a[i][j].back() == '0') {
          a[i][j].pop_back();
          cnt[0][j]++;
          q.push({{i, j}, {1, j}});
          continue;
        }
        cnt[1][j]++;
        a[i][j].pop_back();
        q.push({{i, j}, {n, j}});
      }
  }
  for (int i = 1; i <= m; i++) {
    if (cnt[0][i] < nr[0][i]) {
      for (int j = 1; j <= m; j++)
        if (i != j && cnt[0][j] > nr[0][j]) {
          d = min(nr[0][i] - cnt[0][i], cnt[0][j] - nr[0][j]);
          cnt[0][i] += d;
          cnt[0][j] -= d;
          while (d--) q.push({{1, j}, {1, i}});
        }
    }
    if (cnt[1][i] < nr[1][i]) {
      for (int j = 1; j <= m; j++)
        if (i != j && cnt[1][j] > nr[1][j]) {
          d = min(nr[1][i] - cnt[1][i], cnt[1][j] - nr[1][j]);
          cnt[1][i] += d;
          cnt[1][j] -= d;
          while (d--) q.push({{n, j}, {n, i}});
        }
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 2; i < n; i++)
      for (int h = r[i][j].size() - 1; h >= 0; h--)
        if (r[i][j][h] == '0')
          q.push({{1, j}, {i, j}});
        else
          q.push({{n, j}, {i, j}});
    poz = j + 1;
    if (j == m) poz = j - 1;
    for (int i = r[1][j].size() - 1; i >= 0; i--)
      if (r[1][j][i] == '0') {
        q.push({{1, poz}, {1, j}});
      } else
        q.push({{n, j}, {1, j}});
    for (int i = r[n][j].size() - 1; i >= 0; i--)
      if (r[n][j][i] == '1') {
        q.push({{n, poz}, {n, j}});
      } else
        q.push({{1, j}, {n, j}});
  }
  cout << q.size() << '\n';
  while (!q.empty()) {
    cout << q.front().first.first << ' ' << q.front().first.second << ' ';
    cout << q.front().second.first << ' ' << q.front().second.second << '\n';
    z[q.front().second.first][q.front().second.second] =
        z[q.front().first.first][q.front().first.second].back() +
        z[q.front().second.first][q.front().second.second];
    z[q.front().first.first][q.front().first.second].pop_back();
    q.pop();
  }
}
