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.IOException;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DParquetReLaying solver = new DParquetReLaying();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DParquetReLaying {
        List<int[]> steps = new ArrayList<>((int) 1e5);

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int m = in.readInt();
            char[][] mat = new char[n][m];
            for (int i = 0; i < n; i++) {
                in.readString(mat[i], 0);
            }
            char[][] target = new char[n][m];
            for (int i = 0; i < n; i++) {
                in.readString(target[i], 0);
            }

            List<int[]> cast1 = solve(mat);
            List<int[]> cast2 = solve(target);

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (mat[i][j] != target[i][j]) {
                        out.println(-1);
                        return;
                    }
                }
            }

            SequenceUtils.reverse(cast2);
            cast1.addAll(cast2);
            out.println(cast1.size());
            for (int[] xy : cast1) {
                out.append(xy[0] + 1).append(' ').append(xy[1] + 1).println();
            }
        }

        public void rotate(char[][] mat, int i, int j) {
            steps.add(new int[]{i, j});
            if (mat[i][j] == 'L') {
                mat[i][j + 1] = mat[i][j] = 'U';
                mat[i + 1][j + 1] = mat[i + 1][j] = 'D';
            } else {
                mat[i][j] = mat[i + 1][j] = 'L';
                mat[i][j + 1] = mat[i + 1][j + 1] = 'R';
            }
        }

        public List<int[]> solve(char[][] mat) {
            steps.clear();

            int n = mat.length;
            int m = mat[0].length;

            while (true) {
                // debug.debug("mat", toString(mat));
                boolean goon = false;
                for (int i = 0; i < n - 1 && !goon; i++) {
                    for (int j = 0; j < m - 1 && !goon; j++) {
                        if (mat[i][j] == 'U' && mat[i][j + 1] == 'U') {
                            rotate(mat, i, j);
                            goon = true;
                        } else if (mat[i][j] == 'U' && mat[i][j + 1] == 'L' && mat[i + 1][j + 1] == 'L') {
                            rotate(mat, i, j + 1);
                            goon = true;
                        }
                    }
                }
                if (!goon) {
                    break;
                }
            }

            return new ArrayList<>(steps);
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

    }

    static class SequenceUtils {
        public static <T> void swap(List<T> data, int i, int j) {
            T tmp = data.get(i);
            data.set(i, data.get(j));
            data.set(j, tmp);
        }

        public static <T> void reverse(List<T> data, int l, int r) {
            while (l < r) {
                swap(data, l, r);
                l++;
                r--;
            }
        }

        public static <T> void reverse(List<T> data) {
            reverse(data, 0, data.size() - 1);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}