#include <bits/stdc++.h>
const int N = 55;
int n, m;
char w[2][N][N];
void init() {
  std::cin >> n >> m;
  for (int t = 0; t <= 1; t++) {
    for (int i = 1; i <= n; i++) {
      scanf("%s", w[t][i] + 1);
    }
  }
}
bool check(char x[N][N], int target) {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if ((target == 0 && x[i][j] == 'L') || (target == 1 && x[i][j] == 'U')) {
        return false;
      }
    }
  }
  return true;
}
void trans(char x[N][N], int target,
           std::vector<std::pair<int, int> > &result) {
  while (!check(x, target)) {
    for (int i = 1; i + 1 <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (x[i][j] == 'L' && x[i + 1][j] == 'L') {
          x[i][j] = x[i][j + 1] = 'U';
          x[i + 1][j] = x[i + 1][j + 1] = 'D';
          result.push_back(std::make_pair(i, j));
        }
      }
    }
    if (check(x, target)) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j + 1 <= m; j++) {
        if (x[i][j] == 'U' && x[i][j + 1] == 'U') {
          x[i][j] = x[i + 1][j] = 'L';
          x[i][j + 1] = x[i + 1][j + 1] = 'R';
          result.push_back(std::make_pair(i, j));
        }
      }
    }
  }
}
void work() {
  int target = n & 1;
  std::vector<std::pair<int, int> > answer[2];
  trans(w[0], target, answer[0]);
  trans(w[1], target, answer[1]);
  std::reverse(answer[1].begin(), answer[1].end());
  std::cout << answer[0].size() + answer[1].size() << std::endl;
  for (int t = 0; t <= 1; t++) {
    for (int i = 0; i < (int)answer[t].size(); i++) {
      printf("%d %d\n", answer[t][i].first, answer[t][i].second);
    }
  }
}
int main() {
  init();
  work();
  return 0;
}
