#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double Pi = acos(-1);
using namespace std;
int debug = 01;
int main() {
  vector<pair<pair<int, int>, pair<int, int>>> ans;
  int n, m;
  cin >> n >> m;
  string suf[n][m], pre[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> pre[i][j], reverse(pre[i][j].begin(), pre[i][j].end());
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> suf[i][j], reverse(suf[i][j].begin(), suf[i][j].end());
  for (auto x : pre[0][0]) ans.push_back({{1, 1}, {1, m}});
  ;
  pre[0][m - 1] += pre[0][0];
  for (auto x : pre[n - 1][m - 1]) ans.push_back({{n, m}, {n, 1}});
  ;
  pre[n - 1][0] += pre[n - 1][m - 1];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (!(i + j) || i + j == n + m - 2) continue;
      for (auto x : pre[i][j]) {
        if (x == '0') {
          if (!j)
            ans.push_back({{i + 1, 1}, {1, 1}});
          else {
            ans.push_back({{i + 1, j + 1}, {i + 1, 1}});
            pre[i][0] += "0";
          }
        } else {
          if (j == m - 1)
            ans.push_back({{i + 1, m}, {n, m}});
          else {
            ans.push_back({{i + 1, j + 1}, {i + 1, m}});
            pre[i][m - 1] += "1";
          }
        }
      }
      pre[i][j] = "";
    }
  for (int i = 1; i < n; i++)
    for (auto x : pre[i][0]) ans.push_back({{i + 1, 1}, {1, 1}});
  for (int i = 0; i < n - 1; i++)
    for (auto x : pre[i][m - 1]) ans.push_back({{i + 1, m}, {n, m}});
  for (int i = 1; i < n - 1; i++)
    for (int j = 1; j < m - 1; j++)
      for (auto x : suf[i][j]) {
        if (x == '0') {
          ans.push_back({{1, 1}, {i + 1, 1}});
          ans.push_back({{i + 1, 1}, {i + 1, j + 1}});
        } else {
          ans.push_back({{n, m}, {i + 1, m}});
          ans.push_back({{i + 1, m}, {i + 1, j + 1}});
        }
      }
  for (auto x : suf[0][0]) {
    if (x == '0')
      ans.push_back({{1, 1}, {n, 1}});
    else
      ans.push_back({{n, m}, {n, 1}});
    ans.push_back({{n, 1}, {1, 1}});
    ;
  }
  for (auto x : suf[n - 1][m - 1]) {
    if (x == '0')
      ans.push_back({{1, 1}, {1, m}});
    else
      ans.push_back({{n, m}, {1, m}});
    ;
    ans.push_back({{1, m}, {n, m}});
    ;
  }
  for (int i = 1; i < n - 1; i++)
    for (auto x : suf[i][0]) {
      if (x == '0')
        ans.push_back({{1, 1}, {i + 1, 1}});
      else {
        ans.push_back({{n, m}, {n, 1}});
        ans.push_back({{n, 1}, {i + 1, 1}});
      }
    }
  for (int i = 1; i < n - 1; i++)
    for (auto x : suf[i][m - 1]) {
      if (x == '0') {
        ans.push_back({{1, 1}, {1, m}});
        ans.push_back({{1, m}, {i + 1, m}});
      } else
        ans.push_back({{n, m}, {i + 1, m}});
    }
  for (int j = 1; j < m - 1; j++)
    for (auto x : suf[0][j]) {
      if (x == '0')
        ans.push_back({{1, 1}, {1, j + 1}});
      else {
        ans.push_back({{n, m}, {1, m}});
        ans.push_back({{1, m}, {1, j + 1}});
      }
    }
  for (int j = 1; j < m - 1; j++)
    for (auto x : suf[n - 1][j]) {
      if (x == '0') {
        ans.push_back({{1, 1}, {n, 1}});
        ans.push_back({{n, 1}, {n, j + 1}});
      } else
        ans.push_back({{n, m}, {n, j + 1}});
    }
  for (auto x : suf[n - 1][0]) {
    if (x == '0')
      ans.push_back({{1, 1}, {n, 1}});
    else
      ans.push_back({{n, m}, {n, 1}});
  }
  for (auto x : suf[0][m - 1]) {
    if (x == '0')
      ans.push_back({{1, 1}, {1, m}});
    else
      ans.push_back({{n, m}, {1, m}});
  }
  cout << ans.size() << "\n";
  for (auto x : ans)
    cout << x.first.first << " " << x.first.second << " " << x.second.first
         << " " << x.second.second << "\n";
}
