#include <bits/stdc++.h>
using namespace std;
const int N = 310;
vector<string> a[N], b[N];
string tmp;
int tot = 0;
int plan[100010 * 4][4];
void show() {
  printf("%d\n", tot);
  for (int i = 0; i < tot; ++i)
    for (int j = 0; j < 4; ++j) printf("%d%c", plan[i][j] + 1, " \n"[j == 3]);
}
void move(int a, int b, int c, int d) {
  if (a == c && b == d) return;
  if (a != c && b != d) {
    printf("Wrong! (%d %d) to (%d %d)\n", a, b, c, d);
    exit(0);
  }
  plan[tot][0] = a;
  plan[tot][1] = b;
  plan[tot][2] = c;
  plan[tot][3] = d;
  tot++;
}
void moveto01or10(int x, int y, char ch) {
  if (ch == '0')
    move(x, y, 1, 0);
  else
    move(x, y, 0, 1);
}
void arrange(int x, int y) {
  for (int i = b[x][y].length() - 1; i >= 0; --i)
    if (b[x][y][i] == '0') {
      move(1, 0, x, 0);
      move(x, 0, x, y);
    } else {
      move(0, 1, 0, y);
      move(0, y, x, y);
    }
}
void arrangespecial(int x, int y) {
  for (int i = b[x][y].length() - 1; i >= 0; --i)
    if (b[x][y][i] == '0') {
      move(1, 0, 0, 0);
      move(0, 0, x, y);
    } else {
      move(0, 1, 0, 0);
      move(0, 0, x, y);
    }
}
int main() {
  ios::sync_with_stdio(false);
  int zero = 0, one = 0, n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> tmp;
      a[i].push_back(tmp);
      for (int k = 0; k < tmp.length(); ++k)
        if (tmp[k] == '0')
          ++zero;
        else
          ++one;
    }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> tmp;
      b[i].push_back(tmp);
    }
  for (int i = 1; i < m; ++i) {
    for (int j = a[0][i].length() - 1; j >= 0; --j) move(0, i, 0, 0);
  }
  for (int i = 1; i < n; ++i) {
    for (int j = a[i][0].length() - 1; j >= 0; --j) move(i, 0, 0, 0);
  }
  for (int j = a[0][0].length() - 1; j >= 0; --j)
    moveto01or10(0, 0, a[0][0][j]);
  for (int i = 1; i < m; ++i) {
    for (int j = a[0][i].length() - 1; j >= 0; --j)
      moveto01or10(0, 0, a[0][i][j]);
  }
  for (int i = 1; i < n; ++i)
    for (int j = a[i][0].length() - 1; j >= 0; --j)
      moveto01or10(0, 0, a[i][0][j]);
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j)
      for (int k = a[i][j].length() - 1; k >= 0; --k) {
        if (a[i][j][k] == '0') {
          move(i, j, i, 0);
          move(i, 0, 1, 0);
        } else {
          move(i, j, 0, j);
          move(0, j, 0, 1);
        }
      }
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j) arrange(i, j);
  for (int i = 2; i < n; ++i) arrange(i, 0);
  for (int i = 2; i < m; ++i) arrange(0, i);
  arrangespecial(0, 1);
  arrangespecial(1, 0);
  arrange(0, 0);
  show();
  return 0;
}
