#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vpii = vector<pii>;
const int mxn = 56 * 2;
int n, m;
char s[mxn];
int a[mxn][mxn];
void out() {
  for (int i = 0; i <= n * 2; ++i) {
    for (int j = 0; j <= m * 2; ++j) {
      for (int k = 0; k < (~j & 1 ? 3 : 1); ++k)
        printf("%c", (i & 1) && (j & 1) ? 'O'
                     : a[i][j]          ? (~i & 1 ? '|' : '-')
                                        : ' ');
    }
    puts("");
  }
  puts("");
  puts("");
}
vpii cal() {
  memset(a, 0, sizeof a);
  int n = ::n, m = ::m;
  vpii sol;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    for (int j = 0; j < m; ++j)
      if (s[j] == 'L')
        a[((i)*2 + 1)][((j)*2 + 1) + 1] = 1;
      else if (s[j] == 'U')
        a[((i)*2 + 1) + 1][((j)*2 + 1)] = 1;
  }
  if (::m & 1) {
    for (int i = 0; i <= max(n, m) * 2; ++i)
      for (int j = i; j <= max(n, m) * 2; ++j) swap(a[i][j], a[j][i]);
    swap(n, m);
  }
  function<void(int, int)> get = [&](int x, int y) {
    if (a[x][y]) return;
    get(x + 1, y + 1);
    x += x & 1, y += y & 1;
    sol.push_back({x / 2, y / 2});
    a[x - 1][y] ^= 1;
    a[x + 1][y] ^= 1;
    a[x][y - 1] ^= 1;
    a[x][y + 1] ^= 1;
  };
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; j += 2) get(((i)*2 + 1), ((j)*2 + 1) + 1);
  if (::m & 1) {
    for (auto &i : sol) swap(i.first, i.second);
  }
  return sol;
}
int main() {
  cin >> n >> m;
  auto sa = cal();
  auto sb = cal();
  auto sol = sa;
  reverse(sb.begin(), sb.end());
  for (auto i : sb) sol.push_back(i);
  cout << sol.size() << endl;
  for (auto i : sol) cout << i.first << ' ' << i.second << endl;
  return 0;
}
