#include <bits/stdc++.h>
using namespace std;
const int mxn = 302;
int h, w;
deque<int> dq[mxn][mxn], fin[mxn][mxn];
vector<vector<int> > ans;
void rd(int t) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      string s;
      cin >> s;
      for (auto x : s) {
        if (t == 0)
          dq[i][j].push_back(x - '0');
        else
          fin[i][j].push_back(x - '0');
      }
    }
  }
}
void movex(int sx, int sy, int tx, int ty) {
  int a = dq[sx][sy].back();
  dq[sx][sy].pop_back();
  if (sx == tx) {
    dq[tx][ty].push_front(a);
    ans.push_back({sx, sy, tx, ty});
  } else if (sy == ty) {
    dq[tx][ty].push_front(a);
    ans.push_back({sx, sy, tx, ty});
  } else {
    ans.push_back({sx, sy, tx, sy});
    ans.push_back({tx, sy, tx, ty});
    dq[tx][ty].push_front(a);
  }
}
void movey(int sx, int sy, int tx, int ty) {
  int a = dq[sx][sy].back();
  dq[sx][sy].pop_back();
  if (sx == tx) {
    dq[tx][ty].push_front(a);
    ans.push_back({sx, sy, tx, ty});
  } else if (sy == ty) {
    dq[tx][ty].push_front(a);
    ans.push_back({sx, sy, tx, ty});
  } else {
    ans.push_back({sx, sy, sx, ty});
    ans.push_back({sx, ty, tx, ty});
    dq[tx][ty].push_front(a);
  }
}
void printboard() {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << " . ";
      for (auto x : dq[i][j]) {
        cout << x;
      }
      cout << " . ";
      if (j < w - 1) cout << " o.o ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> h >> w;
  rd(0);
  rd(1);
  while ((int)(dq[0][0]).size()) movex(0, 0, 0, w - 1);
  while ((int)(dq[h - 1][w - 1]).size()) movex(h - 1, w - 1, 0, w - 1);
  for (int i = 0; i < h; i++) {
    for (int j = w - 1; j >= 0; j--) {
      if ((i == 0 and j == 0) or (i == h - 1 and j == w - 1)) continue;
      while ((int)(dq[i][j]).size()) {
        if (dq[i][j].back() == 1)
          movey(i, j, h - 1, w - 1);
        else
          movex(i, j, 0, 0);
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = w - 1; j >= 0; j--) {
      if ((i == 0 and j == 0) or (i == h - 1 and j == w - 1) or
          (i == 0 and j == w - 1))
        continue;
      for (int k = (int)(fin[i][j]).size() - 1; k >= 0; k--) {
        if (fin[i][j][k] == 1) {
          movey(h - 1, w - 1, i, j);
        } else {
          movex(0, 0, i, j);
        }
      }
    }
  }
  for (int k = (int)(fin[0][0]).size() - 1; k >= 0; k--) {
    if (fin[0][0][k] == 1) {
      movex(h - 1, w - 1, 0, 0);
    } else {
      movex(0, 0, 0, w - 1);
      movex(0, w - 1, 0, 0);
    }
  }
  for (int k = (int)(fin[h - 1][w - 1]).size() - 1; k >= 0; k--) {
    if (fin[h - 1][w - 1][k] == 1) {
      movex(h - 1, w - 1, 0, w - 1);
      movex(0, w - 1, h - 1, w - 1);
    } else {
      movey(0, 0, h - 1, w - 1);
    }
  }
  for (int k = (int)(fin[0][w - 1]).size() - 1; k >= 0; k--) {
    if (fin[0][w - 1][k] == 1) {
      movex(h - 1, w - 1, 0, w - 1);
    } else {
      movex(0, 0, 0, w - 1);
    }
  }
  cout << (int)(ans).size() << "\n";
  for (auto v : ans) {
    for (auto x : v) cout << x + 1 << " ";
    cout << "\n";
  }
  return 0;
}
