#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[110][110];
int ansx[100010];
int ansy[100010];
int k;
void work(int x, int y) {
  k++;
  ansx[k] = x;
  ansy[k] = y;
  if (s[x][y] == 'L') {
    s[x][y] = 'U';
    s[x][y + 1] = 'U';
    s[x + 1][y] = 'D';
    s[x + 1][y + 1] = 'D';
  } else {
    s[x][y] = 'L';
    s[x][y + 1] = 'R';
    s[x + 1][y] = 'L';
    s[x + 1][y + 1] = 'R';
  }
  return;
}
void rotate(int x, int y) {
  if (s[x][y] == 'L') {
    if (s[x + 1][y] != 'L') rotate(x + 1, y);
    work(x, y);
  } else if (s[x][y] == 'U') {
    if (s[x][y + 1] != 'U') rotate(x, y + 1);
    work(x, y);
  }
  return;
}
vector<pair<int, int> > vec;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  if (m % 2 == 0) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j += 2)
        if (s[i][j] != 'L') rotate(i, j);
  } else {
    for (int j = 1; j <= m; j++)
      for (int i = 1; i <= n; i += 2)
        if (s[i][j] != 'U') rotate(i, j);
  }
  for (int i = 1; i <= k; i++) vec.push_back(make_pair(ansx[i], ansy[i]));
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  k = 0;
  if (m % 2 == 0) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j += 2)
        if (s[i][j] != 'L') rotate(i, j);
  } else {
    for (int j = 1; j <= m; j++)
      for (int i = 1; i <= n; i += 2)
        if (s[i][j] != 'U') rotate(i, j);
  }
  for (int i = k; i >= 1; i--) vec.push_back(make_pair(ansx[i], ansy[i]));
  printf("%d\n", vec.size());
  for (int i = 0; i < vec.size(); i++)
    printf("%d %d\n", vec[i].first, vec[i].second);
  return 0;
}
