#include <bits/stdc++.h>
const int N = 305, inf = 0x3f3f3f3f;
int n, m;
std::deque<char> a[N][N];
std::vector<std::tuple<int, int, int, int> > A, B;
void collect(std::vector<std::tuple<int, int, int, int> > &ret, int x, int y,
             int x1, int y1, int x2, int y2, int max = inf) {
  int nx, ny;
  while (a[x][y].size() && max--) {
    char c = a[x][y].back();
    a[x][y].pop_back();
    if (c == '0')
      nx = x1, ny = y1;
    else
      nx = x2, ny = y2;
    ret.emplace_back(x, y, nx, ny);
    a[nx][ny].emplace_front(c);
  }
}
void solve(std::vector<std::tuple<int, int, int, int> > &ret) {
  int p = a[0][0].size(), q = a[0][m - 1].size();
  collect(ret, 0, 0, 1, 0, 0, m - 1, p);
  collect(ret, 0, m - 1, 0, 0, 1, m - 1, q);
  for (int i = 0; i < n; ++i)
    for (int j = 1; j < m - 1; ++j) collect(ret, i, j, i, 0, i, m - 1);
  for (int i = 1; i < n; ++i) {
    collect(ret, i, 0, 0, 0, i, m - 1);
    collect(ret, i, m - 1, i, 0, 0, m - 1);
    collect(ret, i, 0, 0, 0, i, m - 1);
  }
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m;
  std::string s;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      std::cin >> s, a[i][j] = std::deque<char>(s.begin(), s.end());
  solve(A);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      std::cin >> s, a[i][j] = std::deque<char>(s.rbegin(), s.rend());
  solve(B);
  std::reverse(B.begin(), B.end());
  std::cout << A.size() + B.size() << '\n';
  for (auto e : A)
    std::cout << std::get<0>(e) + 1 << ' ' << std::get<1>(e) + 1 << ' '
              << std::get<2>(e) + 1 << ' ' << std::get<3>(e) + 1 << '\n';
  for (auto e : B)
    std::cout << std::get<2>(e) + 1 << ' ' << std::get<3>(e) + 1 << ' '
              << std::get<0>(e) + 1 << ' ' << std::get<1>(e) + 1 << '\n';
  return 0;
}
