#include <bits/stdc++.h>
using namespace std;
char s[100][100];
int n, m, x[100100], y[100100], cnt;
void solve() {
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> (s[i] + 1);
    for (int j = 1; j <= m; ++j) {
      if (s[i][j] == 'L' && (n % 2 == 0)) ++sum;
      if (s[i][j] == 'U' && (n & 1)) ++sum;
    }
  }
  for (; sum;) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        if (s[i][j] == 'U' && s[i][j + 1] == 'U') {
          ++cnt;
          x[cnt] = i;
          y[cnt] = j;
          s[i][j] = s[i + 1][j] = 'L';
          s[i][j + 1] = 'R';
          if (n & 1)
            sum -= 2;
          else
            sum += 2;
        }
    if (!sum) return;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        if (s[i][j] == 'L' && s[i + 1][j] == 'L') {
          ++cnt;
          x[cnt] = i;
          y[cnt] = j;
          s[i][j] = s[i][j + 1] = 'U';
          s[i + 1][j] = 'D';
          if (n & 1)
            sum += 2;
          else
            sum -= 2;
        }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  solve();
  int mcnt = cnt;
  solve();
  cout << cnt << '\n';
  for (int i = 1; i <= mcnt; ++i) cout << x[i] << ' ' << y[i] << '\n';
  for (int i = cnt; i > mcnt; --i) cout << x[i] << ' ' << y[i] << '\n';
  return 0;
}
