#include <bits/stdc++.h>
using namespace std;
int N, M;
string beginStr[301][301];
string endStr[301][301];
stringstream ss;
int rowsBlack[301];
int colsWhite[301];
int num;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      cin >> beginStr[i][j];
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      cin >> endStr[i][j];
    }
  }
  reverse(beginStr[1][1].begin(), beginStr[1][1].end());
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (i == 1 && j == 1) continue;
      for (int k = beginStr[i][j].size() - 1; k >= 0; k--) {
        if (beginStr[i][j][k] == '0') {
          int col;
          if (i == 1 || j == 1) {
            col = 1;
            beginStr[1][1] += '0';
          } else {
            col = j;
            colsWhite[j]++;
          }
          num++;
          ss << i << ' ' << j << ' ' << 1 << ' ' << col << '\n';
        } else {
          int row;
          if (j == 1 || i == 1) {
            beginStr[1][1] += '1';
            row = 1;
          } else {
            row = i;
            rowsBlack[i]++;
          }
          num++;
          ss << i << ' ' << j << ' ' << row << ' ' << 1 << '\n';
        }
      }
    }
  }
  reverse(beginStr[1][1].begin(), beginStr[1][1].end());
  for (int i = beginStr[1][1].size() - 1; i >= 0; i--) {
    if (beginStr[1][1][i] == '0') {
      colsWhite[2]++;
      num++;
      ss << 1 << ' ' << 1 << ' ' << 1 << ' ' << 2 << '\n';
    } else {
      rowsBlack[2]++;
      num++;
      ss << 1 << ' ' << 1 << ' ' << 2 << ' ' << 1 << '\n';
    }
  }
  int currRow = 2, currCol = 2;
  for (int i = 2; i <= N; i++) {
    for (int j = 2; j <= M; j++) {
      for (int k = endStr[i][j].size() - 1; k >= 0; k--) {
        if (endStr[i][j][k] == '0') {
          while (colsWhite[currCol] == 0) {
            currCol++;
          }
          colsWhite[currCol]--;
          if (j != currCol) {
            num++;
            ss << 1 << ' ' << currCol << ' ' << 1 << ' ' << j << '\n';
          }
          num++;
          ss << 1 << ' ' << j << ' ' << i << ' ' << j << '\n';
        } else {
          while (rowsBlack[currRow] == 0) {
            currRow++;
          }
          rowsBlack[currRow]--;
          if (i != currRow) {
            num++;
            ss << currRow << ' ' << 1 << ' ' << i << ' ' << 1 << '\n';
          }
          num++;
          ss << i << ' ' << 1 << ' ' << i << ' ' << j << '\n';
        }
      }
    }
  }
  for (int i = 2; i <= N; i++) {
    for (int k = endStr[i][1].size() - 1; k >= 0; k--) {
      if (endStr[i][1][k] == '0') {
        while (colsWhite[currCol] == 0) {
          currCol++;
        }
        colsWhite[currCol]--;
        num += 2;
        ss << 1 << ' ' << currCol << ' ' << 1 << ' ' << 1 << '\n';
        ss << 1 << ' ' << 1 << ' ' << i << ' ' << 1 << '\n';
      } else {
        while (rowsBlack[currRow] == 0) {
          currRow++;
        }
        rowsBlack[currRow]--;
        num += 2;
        ss << currRow << ' ' << 1 << ' ' << 1 << ' ' << 1 << '\n';
        ss << 1 << ' ' << 1 << ' ' << i << ' ' << 1 << '\n';
      }
    }
  }
  for (int j = 2; j <= M; j++) {
    for (int k = endStr[1][j].size() - 1; k >= 0; k--) {
      if (endStr[1][j][k] == '0') {
        while (colsWhite[currCol] == 0) {
          currCol++;
        }
        colsWhite[currCol]--;
        num += 2;
        ss << 1 << ' ' << currCol << ' ' << 1 << ' ' << 1 << '\n';
        ss << 1 << ' ' << 1 << ' ' << 1 << ' ' << j << '\n';
      } else {
        while (rowsBlack[currRow] == 0) {
          currRow++;
        }
        rowsBlack[currRow]--;
        num += 2;
        ss << currRow << ' ' << 1 << ' ' << 1 << ' ' << 1 << '\n';
        ss << 1 << ' ' << 1 << ' ' << 1 << ' ' << j << '\n';
      }
    }
  }
  for (int k = endStr[1][1].size() - 1; k >= 0; k--) {
    if (endStr[1][1][k] == '0') {
      while (colsWhite[currCol] == 0) {
        currCol++;
      }
      colsWhite[currCol]--;
      num++;
      ss << 1 << ' ' << currCol << ' ' << 1 << ' ' << 1 << '\n';
    } else {
      while (rowsBlack[currRow] == 0) {
        currRow++;
      }
      rowsBlack[currRow]--;
      num++;
      ss << currRow << ' ' << 1 << ' ' << 1 << ' ' << 1 << '\n';
    }
  }
  cout << num << '\n' << ss.str();
  return 0;
}
