#include <bits/stdc++.h>
using namespace std;
int N, M;
char S[60][60];
int A[100000][2], B[100000][2], LA, LB;
void opr(int x, int y) {
  if (S[x][y] == 'U') {
    S[x][y] = S[x + 1][y] = 'L';
    S[x][y + 1] = S[x + 1][y + 1] = 'R';
  } else {
    S[x][y] = S[x][y + 1] = 'U';
    S[x + 1][y] = S[x + 1][y + 1] = 'D';
  }
}
void slv(int (&D)[100000][2], int &L) {
  for (int i = 0; i < N; ++i) scanf("%s", S[i]);
  int w = 0;
  char ng = N & 1 ? 'U' : 'L';
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      if (S[i][j] == ng) ++w;
  if (N & 1)
    while (w) {
      for (int i = 0; i < N - 1; ++i)
        for (int j = 0; j < M - 1; ++j)
          if (S[i][j] == 'U' && S[i][j + 1] == 'U') {
            opr(D[L][0] = i, D[L][1] = j);
            ++L;
            w -= 2;
          }
      if (!w) break;
      for (int i = 0; i < N - 1; ++i)
        for (int j = 0; j < M - 1; ++j)
          if (S[i][j] == 'L' && S[i + 1][j] == 'L') {
            opr(D[L][0] = i, D[L][1] = j);
            ++L;
            w += 2;
          }
    }
  else
    while (w) {
      for (int i = 0; i < N - 1; ++i)
        for (int j = 0; j < M - 1; ++j)
          if (S[i][j] == 'L' && S[i + 1][j] == 'L') {
            opr(D[L][0] = i, D[L][1] = j);
            ++L;
            w -= 2;
          }
      if (!w) break;
      for (int i = 0; i < N - 1; ++i)
        for (int j = 0; j < M - 1; ++j)
          if (S[i][j] == 'U' && S[i][j + 1] == 'U') {
            opr(D[L][0] = i, D[L][1] = j);
            ++L;
            w += 2;
          }
    }
}
int main() {
  scanf("%d%d", &N, &M);
  slv(A, LA);
  slv(B, LB);
  printf("%d\n", LA + LB);
  for (int i = 0; i < LA; ++i) printf("%d %d\n", A[i][0] + 1, A[i][1] + 1);
  for (int i = LB - 1; i >= 0; --i) printf("%d %d\n", B[i][0] + 1, B[i][1] + 1);
  return 0;
}
