#include <bits/stdc++.h>
using namespace std;
const int N = 303;
struct op {
  int x1, y1, x2, y2;
};
vector<op> out;
string must[N][N];
string init[N][N];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < m; j++) cin >> init[i][j];
  }
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < m; j++) cin >> must[i][j];
  }
  for (auto j = 1; j < m; j++) {
    int L = (int)init[0][j].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[0][j][k] == '0') {
        out.push_back(op{0, j, 0, 0});
      } else {
        if (j == 1) {
          out.push_back(op{0, j, 1, 1});
        } else {
          out.push_back(op{0, j, 0, 1});
          out.push_back(op{0, 1, 1, 1});
        }
      }
    }
  }
  for (auto j = 2; j < m; j++) {
    int L = (int)init[1][j].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[1][j][k] == '0') {
        out.push_back(op{1, j, 0, j});
        out.push_back(op{0, j, 0, 0});
      } else {
        out.push_back(op{1, j, 1, 1});
      }
    }
  }
  for (auto i = 2; i < n; i++) {
    for (auto j = 2; j < m; j++) {
      int L = (int)init[i][j].length();
      for (auto k = L - 1; k >= 0; k--) {
        if (init[i][j][k] == '0') {
          out.push_back(op{i, j, 0, j});
          out.push_back(op{0, j, 0, 0});
        } else {
          out.push_back(op{i, j, 1, j});
          out.push_back(op{1, j, 1, 1});
        }
      }
    }
  }
  for (auto i = 1; i < n; i++) {
    int L = (int)init[i][0].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[i][0][k] == '0') {
        out.push_back(op{i, 0, 0, 0});
      } else {
        if (i == 1) {
          out.push_back(op{i, 0, 1, 1});
        } else {
          out.push_back(op{i, 0, 1, 0});
          out.push_back(op{1, 0, 1, 1});
        }
      }
    }
  }
  for (auto i = 2; i < n; i++) {
    int L = (int)init[i][1].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[i][1][k] == '0') {
        out.push_back(op{i, 1, i, 0});
        out.push_back(op{i, 0, 0, 0});
      } else {
        out.push_back(op{i, 1, 1, 1});
      }
    }
  }
  for (auto c = 0; c < 1; c++) {
    int L = (int)init[0][0].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[0][0][k] == '0') {
        out.push_back(op{0, 0, 1, 0});
        out.push_back(op{1, 0, 0, 0});
      } else {
        out.push_back(op{0, 0, 1, 0});
        out.push_back(op{1, 0, 1, 1});
      }
    }
  }
  for (auto c = 0; c < 1; c++) {
    int L = (int)init[1][1].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (init[1][1][k] == '0') {
        out.push_back(op{1, 1, 1, 0});
        out.push_back(op{1, 0, 0, 0});
      } else {
        out.push_back(op{1, 1, 1, 0});
        out.push_back(op{1, 0, 1, 1});
      }
    }
  }
  for (auto j = m - 1; j >= 2; j--) {
    for (auto i = n - 1; i >= 1; i--) {
      int L = (int)must[i][j].length();
      for (auto k = L - 1; k >= 0; k--) {
        if (must[i][j][k] == '0') {
          out.push_back(op{0, 0, 0, j});
          out.push_back(op{0, j, i, j});
        } else {
          if (i == 1) {
            out.push_back(op{1, 1, 1, j});
          } else {
            out.push_back(op{1, 1, 1, j});
            out.push_back(op{1, j, i, j});
          }
        }
      }
    }
  }
  for (auto j = m - 1; j >= 1; j--) {
    int L = (int)must[0][j].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[0][j][k] == '0')
        out.push_back(op{0, 0, 0, j});
      else {
        if (j == 1)
          out.push_back(op{1, 1, 0, 1});
        else {
          out.push_back(op{1, 1, 0, 1});
          out.push_back(op{0, 1, 0, j});
        }
      }
    }
  }
  for (auto i = n - 1; i >= 2; i--) {
    int L = (int)must[i][1].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[i][1][k] == '0') {
        out.push_back(op{0, 0, i, 0});
        out.push_back(op{i, 0, i, 1});
      } else
        out.push_back(op{1, 1, i, 1});
    }
  }
  for (auto i = n - 1; i >= 2; i--) {
    int L = (int)must[i][0].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[i][0][k] == '0') {
        out.push_back(op{0, 0, i, 0});
      } else {
        out.push_back(op{1, 1, 1, 0});
        out.push_back(op{1, 0, i, 0});
      }
    }
  }
  for (auto c = 0; c < 1; c++) {
    int L = (int)must[0][0].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[0][0][k] == '0') {
        out.push_back(op{0, 0, 1, 0});
        out.push_back(op{1, 0, 0, 0});
      } else {
        out.push_back(op{1, 1, 1, 0});
        out.push_back(op{1, 0, 0, 0});
      }
    }
  }
  for (auto c = 0; c < 1; c++) {
    int L = (int)must[1][1].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[1][1][k] == '0') {
        out.push_back(op{0, 0, 1, 0});
        out.push_back(op{1, 0, 1, 1});
      } else {
        out.push_back(op{1, 1, 1, 0});
        out.push_back(op{1, 0, 1, 1});
      }
    }
  }
  for (auto c = 0; c < 1; c++) {
    int L = (int)must[1][0].length();
    for (auto k = L - 1; k >= 0; k--) {
      if (must[1][0][k] == '0')
        out.push_back(op{0, 0, 1, 0});
      else
        out.push_back(op{1, 1, 1, 0});
    }
  }
  cout << out.size() << endl;
  for (auto x : out) {
    cout << x.x1 + 1 << " " << x.y1 + 1 << " " << x.x2 + 1 << " " << x.y2 + 1
         << '\n';
  }
  return 0;
}
