Problem: Peter decided to lay a parquet in the room of size n × m, the parquet consists of tiles of size 1 × 2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter likes, and workers will have to re-lay it.

The workers decided that removing entire parquet and then laying it again is very difficult task, so they decided to make such an operation every hour: remove two tiles, which form a 2 × 2 square, rotate them 90 degrees and put them back on the same place.

<image>

They have no idea how to obtain the desired configuration using these operations, and whether it is possible at all.

Help Peter to make a plan for the workers or tell that it is impossible. The plan should contain at most 100 000 commands.

Input

The first line contains integer n and m, size of the room (1 ≤ n, m ≤ 50). At least one of them is even number.

The following n lines contain m characters each, the description of the current configuration of the parquet tiles. Each character represents the position of the half-tile. Characters 'L', 'R', 'U' and 'D' correspond to the left, right, upper and lower halves, respectively.

The following n lines contain m characters each, describing the desired configuration in the same format.

Output

In the first line output integer k, the number of operations. In the next k lines output description of operations. The operation is specified by coordinates (row and column) of the left upper half-tile on which the operation is performed.

If there is no solution, output -1 in the first line.

Examples

Input

2 3
ULR
DLR
LRU
LRD


Output

2
1 2
1 1


Input

4 3
ULR
DLR
LRU
LRD
ULR
DUU
UDD
DLR

Output

3
3 1
3 2
2 2

Note

In the first sample test first operation is to rotate two rightmost tiles, after this all tiles lie vertically. Second operation is to rotate two leftmost tiles, after this we will get desired configuration.

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <typename T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <typename T>
inline void println(T first) {
  print(first), putchar('\n');
}
template <typename T>
inline void printsp(T first) {
  print(first), putchar(' ');
}
template <class T, class T1>
inline void print(T first, T1 second) {
  printsp(first), println(second);
}
template <class T, class T1, class T2>
inline void print(T first, T1 second, T2 z) {
  printsp(first), printsp(second), println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[55][55];
int vst[55][55];
vector<pair<int, int> > vec[2];
char t[] = "LURD";
bool can(int first, int second) {
  if (s[first][second] == s[first + 1][second] &&
      s[first][second + 1] == s[first + 1][second + 1])
    return true;
  if (s[first][second] == s[first][second + 1] &&
      s[first + 1][second] == s[first + 1][second + 1])
    return true;
  return false;
}
int vis[55][55], runs;
int n, m;
bool dfs(int first, int second, vector<pair<int, int> > &tmp) {
  tmp.push_back(pair<int, int>(first, second));
  vis[first][second] = runs;
  if (can(first, second)) return true;
  if (s[first][second] == 'L') {
    if (first > 2 && !vst[first - 2][second] &&
        vis[first - 2][second] != runs && s[first - 2][second] == 'U') {
      if (dfs(first - 2, second, tmp)) return true;
    }
    if (first < n - 1 && !vst[first + 1][second] &&
        vis[first + 1][second] != runs && s[first + 1][second] == 'U') {
      if (dfs(first + 1, second, tmp)) return true;
    }
  } else {
    if (second > 2 && !vst[first][second - 2] &&
        vis[first][second - 2] != runs && s[first][second - 2] == 'L') {
      if (dfs(first, second - 2, tmp)) return true;
    }
    if (second < m - 1 && !vst[first][second + 1] &&
        vis[first][second + 1] != runs && s[first][second + 1] == 'L') {
      if (dfs(first, second + 1, tmp)) return true;
    }
  }
  tmp.pop_back();
  return false;
}
void change(int first, int second) {
  if (s[first][second] == 'L') {
    s[first][second] = s[first][second + 1] = 'U';
    s[first + 1][second] = s[first + 1][second + 1] = 'D';
  } else {
    s[first][second] = s[first + 1][second] = 'L';
    s[first][second + 1] = s[first + 1][second + 1] = 'R';
  }
}
void solve(int n, int m, vector<pair<int, int> > &v) {
  int flag = 0;
  if (n & 1) {
    flag = 1;
    swap(n, m);
    for (int i = 1; i < 55; i++)
      for (int j = 1; j < i; j++) swap(s[i][j], s[j][i]);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) s[i][j] = t[(strchr(t, s[i][j]) - t) ^ 1];
  }
  ::n = n, ::m = m;
  memset(vst, 0, sizeof(vst));
  for (int i = 1; i < n; i += 2) {
    for (int j = 1; j <= m;) {
      if (s[i][j] == 'U') {
        vst[i][j] = vst[i + 1][j] = 1;
        j++;
        continue;
      }
      runs++;
      vector<pair<int, int> > tmp;
      dfs(i, j, tmp);
      for (int k = tmp.size(); k--;)
        change(tmp[k].first, tmp[k].second), v.push_back(tmp[k]);
      vst[i][j] = vst[i + 1][j] = vst[i][j + 1] = vst[i + 1][j + 1] = 1;
      j += 2;
    }
  }
  if (flag) {
    for (int i = 0; i < v.size(); i++) swap(v[i].first, v[i].second);
  }
}
int main() {
  int n, m;
  gn(n, m);
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) scanf("%s", s[j] + 1);
    solve(n, m, vec[i]);
  }
  println(vec[0].size() + vec[1].size());
  for (int i = 0; i < vec[0].size(); i++)
    print(vec[0][i].first, vec[0][i].second);
  for (int i = vec[1].size(); i--;) print(vec[1][i].first, vec[1][i].second);
  return 0;
}