#include <bits/stdc++.h>
using namespace std;
int n, m;
int g[55][55], id;
vector<pair<int, int> > res1, res2;
bool chk(bool f) {
  if (f == 0) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j += 2)
        if (g[i][j] != g[i][j + 1]) return false;
  } else {
    for (int i = 0; i < n; i += 2)
      for (int j = 0; j < m; j++)
        if (g[i][j] != g[i + 1][j]) return false;
  }
  return true;
}
void adjust(bool f, vector<pair<int, int> > &res) {
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m - 1; j++)
      if (f == 0) {
        if (g[i][j] == g[i][j + 1] && g[i + 1][j] == g[i + 1][j + 1]) {
          swap(g[i][j + 1], g[i + 1][j]);
          res.push_back(make_pair(i + 1, j + 1));
        }
      } else {
        if (g[i][j] == g[i + 1][j] && g[i][j + 1] == g[i + 1][j + 1]) {
          swap(g[i][j + 1], g[i + 1][j]);
          res.push_back(make_pair(i + 1, j + 1));
        }
      }
}
void proc(vector<pair<int, int> > &res) {
  id = 0;
  for (int i = 0; i < n; i++) {
    char s[55];
    scanf("%s", s);
    for (int j = 0; j < m; j++) {
      if (s[j] == 'U') g[i][j] = g[i + 1][j] = id++;
      if (s[j] == 'L') g[i][j] = g[i][j + 1] = id++;
    }
  }
  res.clear();
  int f = m % 2;
  while (!chk(f)) {
    adjust(f, res);
    adjust(1 - f, res);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  proc(res1);
  proc(res2);
  printf("%d\n", res1.size() + res2.size());
  for (int i = 0; i < res1.size(); i++)
    printf("%d %d\n", res1[i].first, res1[i].second);
  for (int i = res2.size() - 1; i >= 0; i--)
    printf("%d %d\n", res2[i].first, res2[i].second);
  return 0;
}
