#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int n, m;
string tmp[333][333];
string a[333][333];
int eo[333];
string b[333][333];
char t[111111];
int main() {
  int s = 0;
  cin >> n >> m;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      scanf("%s", t);
      a[i][j] = t;
      tmp[i][j] = t;
      s += a[i][j].size();
    }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      scanf("%s", t);
      b[i][j] = t;
    }
  vector<int> r;
  for (int i = (0); i < (a[0][0].size()); i++) {
    r.push_back(0);
    r.push_back(0);
    r.push_back(0);
    r.push_back(1);
  }
  a[0][1] = a[0][0] + a[0][1];
  a[0][0] = "";
  for (int i = (0); i < (a[1][1].size()); i++) {
    r.push_back(1);
    r.push_back(1);
    r.push_back(1);
    r.push_back(0);
  }
  a[1][0] = a[1][1] + a[1][0];
  a[1][1] = "";
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      if (i == 1 && j == 1) continue;
      if (i == 1 && eo[j]) {
        a[i][j] = string(eo[j], '1') + a[i][j];
      }
      while (!a[i][j].empty()) {
        if (a[i][j].back() == '0') {
          r.push_back(i);
          r.push_back(j);
          if (i == 0 || j == 0) {
          } else {
            r.push_back(0);
            r.push_back(j);
            r.push_back(0);
            r.push_back(j);
          }
          r.push_back(0);
          r.push_back(0);
          a[i][j].pop_back();
          a[0][0].push_back('0');
        } else {
          r.push_back(i);
          r.push_back(j);
          if (i == 1 || j == 1) {
          } else if (i == 0) {
            eo[j]++;
            r.push_back(1);
            r.push_back(j);
            a[i][j].pop_back();
            continue;
          } else {
            r.push_back(1);
            r.push_back(j);
            r.push_back(1);
            r.push_back(j);
          }
          r.push_back(1);
          r.push_back(1);
          a[i][j].pop_back();
          a[1][1].push_back('1');
        }
      }
    }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) reverse(b[i][j].begin(), b[i][j].end());
  for (int i = (2); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      for (int k = (0); k < (b[i][j].size()); k++) {
        if (b[i][j][k] == '0') {
          r.push_back(0);
          r.push_back(0);
          if (j != 0) {
            r.push_back(0);
            r.push_back(j);
            r.push_back(0);
            r.push_back(j);
          }
          r.push_back(i);
          r.push_back(j);
        } else {
          r.push_back(1);
          r.push_back(1);
          if (j != 1) {
            r.push_back(1);
            r.push_back(j);
            r.push_back(1);
            r.push_back(j);
          }
          r.push_back(i);
          r.push_back(j);
        }
      }
    }
  for (int j = (2); j < (m); j++) {
    for (int k = (0); k < (b[0][j].size()); k++) {
      if (b[0][j][k] == '0') {
        r.push_back(0);
        r.push_back(0);
        r.push_back(0);
        r.push_back(j);
      } else {
        r.push_back(1);
        r.push_back(1);
        r.push_back(0);
        r.push_back(1);
        r.push_back(0);
        r.push_back(1);
        r.push_back(0);
        r.push_back(j);
      }
    }
  }
  for (int j = (2); j < (m); j++) {
    for (int k = (0); k < (b[1][j].size()); k++) {
      if (b[1][j][k] == '0') {
        r.push_back(0);
        r.push_back(0);
        r.push_back(1);
        r.push_back(0);
        r.push_back(1);
        r.push_back(0);
        r.push_back(1);
        r.push_back(j);
      } else {
        r.push_back(1);
        r.push_back(1);
        r.push_back(1);
        r.push_back(j);
      }
    }
  }
  string t1 = b[0][0] + b[0][1];
  for (int i = (0); i < (t1.size()); i++) {
    if (t1[i] == '0') {
      r.push_back(0);
      r.push_back(0);
      r.push_back(0);
      r.push_back(1);
    } else {
      r.push_back(1);
      r.push_back(1);
      r.push_back(0);
      r.push_back(1);
    }
  }
  string t2 = b[1][1] + b[1][0];
  for (int i = (0); i < (t2.size()); i++) {
    if (t2[i] == '0') {
      r.push_back(0);
      r.push_back(0);
      r.push_back(1);
      r.push_back(0);
    } else {
      r.push_back(1);
      r.push_back(1);
      r.push_back(1);
      r.push_back(0);
    }
  }
  for (int i = (0); i < (b[0][0].size()); i++) {
    r.push_back(0);
    r.push_back(1);
    r.push_back(0);
    r.push_back(0);
  }
  for (int i = (0); i < (b[1][1].size()); i++) {
    r.push_back(1);
    r.push_back(0);
    r.push_back(1);
    r.push_back(1);
  }
  cout << r.size() / 4 << endl;
  for (int i = (0); i < (r.size()); i++) {
    printf("%d ", r[i] + 1);
    if (i % 4 == 3) puts("");
  }
  return 0;
  while (r.size() / 4 > s * 4) puts("MASTER FUCK");
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) reverse(b[i][j].begin(), b[i][j].end());
  for (int i = 0; i < r.size(); i += 4) {
    int x1 = r[i];
    int y1 = r[i + 1];
    int x2 = r[i + 2];
    int y2 = r[i + 3];
    cout << i << ": " << endl;
    while (tmp[x1][y1] == "") puts("FUCK");
    if (x1 == x2 && y1 == y2) {
      puts("FUCK2");
      while (1)
        ;
    }
    tmp[x2][y2] = string(1, tmp[x1][y1].back()) + tmp[x2][y2];
    tmp[x1][y1].pop_back();
    cout << "step" << endl;
    for (int ii = (0); ii < (n); ii++) {
      for (int jj = (0); jj < (m); jj++) cout << tmp[ii][jj] << ' ';
      puts("");
    }
  }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++)
      if (tmp[i][j] != b[i][j]) {
        puts("FUCK3");
      }
  return 0;
}
