#include <bits/stdc++.h>
using namespace std;
const int N = 305;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
int n, m;
list<char> s[N][N];
vector<char> g[N][N];
int answ;
pair<pair<int, int>, pair<int, int> > p[400005];
void go(int x1, int u1, int x2, int u2) {
  if (x1 == x2 && u1 == u2) {
    if (x1 == 1) {
      ++answ;
      p[answ].first = make_pair(x1, u1);
      p[answ].second = make_pair(x1, u1 + 1);
      ++answ;
      p[answ].first = make_pair(x1, u1 + 1);
      p[answ].second = make_pair(x1, u1);
    } else {
      ++answ;
      p[answ].first = make_pair(x1, u1);
      p[answ].second = make_pair(x1, u1 - 1);
      ++answ;
      p[answ].first = make_pair(x1, u1 - 1);
      p[answ].second = make_pair(x1, u1);
    }
    return;
  }
  if (x1 == x2 || u1 == u2) {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(x2, u2);
    return;
  }
  if (x1 == 1) {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(x1, u2);
    ++answ;
    p[answ].first = make_pair(x1, u2);
    p[answ].second = make_pair(x2, u2);
  } else {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(x2, u1);
    ++answ;
    p[answ].first = make_pair(x2, u1);
    p[answ].second = make_pair(x2, u2);
  }
}
void G(int x1, int u1, int x2, int u2) {
  if (x1 == x2 && u1 == u2) {
    if (x2 == 1) {
      ++answ;
      p[answ].first = make_pair(x1, u1);
      p[answ].second = make_pair(x1, u1 + 1);
      s[x1][u1 + 1].push_front('0');
    } else {
      ++answ;
      p[answ].first = make_pair(x1, u1);
      p[answ].second = make_pair(x1, u1 - 1);
      s[x1][u1 - 1].push_front('1');
    }
    return;
  }
  if (x1 == x2 || u1 == u2) {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(x2, u2);
    return;
  }
  if (x2 == 1) {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(1, u1);
    s[1][u1].push_front('0');
  } else {
    ++answ;
    p[answ].first = make_pair(x1, u1);
    p[answ].second = make_pair(n, u1);
    s[n][u1].push_front('1');
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      string ss;
      cin >> ss;
      for (int h = 0; h < (int)ss.size(); h++) {
        s[i][j].push_back(ss[h]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      string ss;
      cin >> ss;
      for (int h = 0; h < (int)ss.size(); h++) {
        g[i][j].push_back(ss[h]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      while ((int)s[i][j].size()) {
        char x = s[i][j].back();
        s[i][j].pop_back();
        if (x == '0') {
          G(i, j, 1, 1);
        } else {
          G(i, j, n, m);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      while ((int)s[i][j].size()) {
        char x = s[i][j].back();
        s[i][j].pop_back();
        if (x == '0') {
          G(i, j, 1, 1);
        } else {
          G(i, j, n, m);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      while ((int)s[i][j].size()) {
        char x = s[i][j].back();
        s[i][j].pop_back();
        if (x == '0') {
          G(i, j, 1, 1);
        } else {
          G(i, j, n, m);
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (i == n) {
      for (int j = m; j >= 1; j--) {
        while ((int)g[i][j].size()) {
          char x = g[i][j].back();
          g[i][j].pop_back();
          if (x == '0') {
            go(1, 1, i, j);
          } else {
            go(n, m, i, j);
          }
        }
      }
    } else {
      for (int j = 1; j <= m; j++) {
        while ((int)g[i][j].size()) {
          char x = g[i][j].back();
          g[i][j].pop_back();
          if (x == '0') {
            go(1, 1, i, j);
          } else {
            go(n, m, i, j);
          }
        }
      }
    }
  }
  printf("%d\n", answ);
  for (int i = 1; i <= answ; i++) {
    printf("%d %d %d %d\n", p[i].first.first, p[i].first.second,
           p[i].second.first, p[i].second.second);
  }
  return 0;
}
