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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        FastWriter out = new FastWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastReader in, FastWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            Parquet a, b;
            boolean rotated = false;
            char transformChar[] = new char[128];
            transformChar['L'] = 'U';
            transformChar['R'] = 'D';
            transformChar['U'] = 'L';
            transformChar['D'] = 'R';
            if (m % 2 > 0) {
                a = new Parquet(m, n);
                b = new Parquet(m, n);
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        a.v[j][i] = transformChar[in.nextChar()];
                    }
                }
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        b.v[j][i] = transformChar[in.nextChar()];
                    }
                }
                rotated = true;
            } else {
                a = new Parquet(n, m);
                b = new Parquet(n, m);
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        a.v[i][j] = in.nextChar();
                    }
                }
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        b.v[i][j] = in.nextChar();
                    }
                }
            }
            ArrayList<Pair<Integer, Integer>> r = a.transform();
            ArrayList<Pair<Integer, Integer>> r2 = b.transform();
            Collections.reverse(r2);
            r.addAll(r2);
            out.println(r.size());
            for (Pair<Integer, Integer> pair : r) {
                if (rotated)
                    out.println(pair.y + 1, pair.x + 1);
                else
                    out.println(pair.x + 1, pair.y + 1);
            }
        }

        class Parquet {
            char[][] v;

            public Parquet(int n, int m) {
                v = new char[n][m];
            }

            ArrayList<Pair<Integer, Integer>> transform() {
                ArrayList<Pair<Integer, Integer>> res = new ArrayList<>();
                for (int i = 0; i < v.length; ++i) {
                    for (int j = 0; j < v[0].length; j += 2) {
                        go(i, j, res, 0, 1);
                    }
                }
                return res;
            }

            private void go(int i, int j, ArrayList<Pair<Integer, Integer>> res, int dy, int dx) {
                if (v[i][j] == 'L' && dx == 1) return;
                if (v[i][j] == 'U' && dy == 1) return;
                go(i + dy, j + dx, res, dx, dy);
                rotate(i, j, res);
            }

            private void rotate(int i, int j, ArrayList<Pair<Integer, Integer>> res) {
                res.add(new Pair<>(i, j));
                if (v[i][j] == 'L') {
                    v[i][j] = 'U';
                    v[i][j + 1] = 'U';
                    v[i + 1][j] = 'D';
                    v[i + 1][j + 1] = 'D';
                } else {
                    v[i][j] = 'L';
                    v[i][j + 1] = 'R';
                    v[i + 1][j] = 'L';
                    v[i + 1][j + 1] = 'R';
                }
            }

        }

    }

    static class FastReader {
        final int EOF = -1;
        InputStream stream;
        byte[] buf = new byte[8192];
        int bufSize;
        int bufPos;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (bufPos >= bufSize) {
                bufPos = 0;
                try {
                    bufSize = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufSize <= 0) {
                    return EOF;
                }
            }
            return buf[bufPos++];
        }

        public int nextInt() {
            int c = read();
            while (isSpace(c)) {
                c = read();
            }
            int sign = 1;
            if (c == '-') {
                sign = EOF;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = res * 10 + c - '0';
                c = read();
            } while (!isSpace(c));
            return res * sign;
        }

        public char nextChar() {
            int c = read();
            while (isSpace(c)) {
                c = read();
            }
            return (char) c;
        }

        public boolean isSpace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == EOF;
        }

    }

    static class Pair<X, Y> implements Comparable<Pair<X, Y>> {
        public X x;
        public Y y;

        public Pair(X x, Y y) {
            this.x = x;
            this.y = y;
        }


        public int hashCode() {
            int res = x == null ? 0 : x.hashCode();
            return res * 31 + (y == null ? 0 : y.hashCode());
        }


        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null) return false;
            if (getClass() != o.getClass()) return false;
            Pair p = (Pair) o;
            if ((x == null && p.x != null) || !x.equals(p.x)) return false;
            if ((y == null && p.y != null) || !y.equals(p.y)) return false;
            return true;
        }


        public String toString() {
            return String.format("(" + x + ", " + y + ")");
        }


        @SuppressWarnings({"unchecked"})
        public int compareTo(Pair<X, Y> o) {
            int res = ((Comparable<X>) x).compareTo(o.x);
            if (res != 0) return res;
            return ((Comparable<Y>) y).compareTo(o.y);
        }

    }

    static class FastWriter {
        PrintWriter writer;

        public FastWriter(OutputStream stream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
        }

        public FastWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i > 0) writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void println(int i) {
            writer.println(i);
        }

        public void close() {
            writer.close();
        }

    }
}