#include <bits/stdc++.h>
using namespace std;
int n, m;
string board[50];
vector<pair<int, int>> moves1, moves2;
void rotate(int x, int y) {
  if (board[x][y] == 'L') {
    board[x][y] = board[x][y + 1] = 'U';
    board[x + 1][y] = board[x + 1][y + 1] = 'D';
  } else {
    board[x][y] = board[x + 1][y] = 'L';
    board[x][y + 1] = board[x + 1][y + 1] = 'R';
  }
}
void fix(int x, int y, vector<pair<int, int>> &moves) {
  if (board[x + 1][y] == 'U') {
    if (board[x + 1][y + 1] == 'L') fix(x + 1, y + 1, moves);
    rotate(x + 1, y);
    moves.push_back({x + 2, y + 1});
  }
  rotate(x, y);
  moves.push_back({x + 1, y + 1});
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> board[i];
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m; j++)
      if (board[i][j] == 'L') fix(i, j, moves1);
  for (int i = 0; i < n; i++) cin >> board[i];
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m; j++)
      if (board[i][j] == 'L') fix(i, j, moves2);
  cout << moves1.size() + moves2.size() << endl;
  for (int i = 0; i < moves1.size(); i++)
    cout << moves1[i].first << " " << moves1[i].second << endl;
  for (int i = moves2.size() - 1; i >= 0; i--)
    cout << moves2[i].first << " " << moves2[i].second << endl;
  return 0;
}
