There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.

Snuke can apply the following operation to this grid any number of times:

* Choose two different rows and swap them. Or, choose two different columns and swap them.



Snuke wants this grid to be symmetric. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.

Determine if Snuke can achieve this objective.

Constraints

* 1 \leq H \leq 12
* 1 \leq W \leq 12
* |S_i| = W
* S_i consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


H W
S_1
S_2
:
S_H


Output

If Snuke can make the grid symmetric, print `YES`; if he cannot, print `NO`.

Examples

Input

2 3
arc
rac


Output

YES


Input

3 7
atcoder
regular
contest


Output

NO


Input

12 12
bimonigaloaf
faurwlkbleht
dexwimqxzxbb
lxdgyoifcxid
ydxiliocfdgx
nfoabgilamoi
ibxbdqmzxxwe
pqirylfrcrnf
wtehfkllbura
yfrnpflcrirq
wvcclwgiubrk
lkbrwgwuiccv


Output

YES
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 * 
 * @author daltao
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "daltao", 1 << 27);
        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);
            PrintWriter out = new PrintWriter(outputStream);
            TaskE solver = new TaskE();
            solver.solve(1, in, out);
            out.close();
        }
    }
    static class TaskE {
        int h;
        int w;
        char[][] mat;
        boolean valid = false;
        boolean[] matched;

        public void solve(int testNumber, FastInput in, PrintWriter out) {
            h = in.readInt();
            w = in.readInt();

            matched = new boolean[w];
            mat = new char[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    mat[i][j] = in.readChar();
                }
            }

            prepareGroup(0, h - 1, 0);

            out.println(valid ? "YES" : "NO");
        }

        public boolean match(int i, int j) {
            for (int k = 0; k < h; k++) {
                if (mat[k][i] != mat[h - 1 - k][j]) {
                    return false;
                }
            }
            return true;
        }

        public void check() {
            Arrays.fill(matched, false);
            int single = 0;
            for (int i = 0; i < w; i++) {
                if (matched[i]) {
                    continue;
                }
                for (int j = i + 1; j < w; j++) {
                    if (match(i, j)) {
                        matched[i] = matched[j] = true;
                        break;
                    }
                }

                if (!matched[i]) {
                    if (single < w % 2 && match(i, i)) {
                        matched[i] = true;
                        single++;
                    }
                }

                if (!matched[i]) {
                    return;
                }
            }

            valid = true;
        }

        public void prepareGroup(int l, int r, int single) {
            if (valid) {
                return;
            }

            if (l >= r) {
                check();
                return;
            }

            if (single < h % 2) {
                SequenceUtils.swap(mat, l, h / 2);
                prepareGroup(l, r, single + 1);
                SequenceUtils.swap(mat, l, h / 2);
            }

            for (int i = l + 1; i <= r; i++) {
                SequenceUtils.swap(mat, i, r);
                prepareGroup(l + 1, r - 1, single);
                SequenceUtils.swap(mat, i, r);
            }
        }

    }
    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 char readChar() {
            skipBlank();
            char c = (char) next;
            next = read();
            return c;
        }

    }
    static class SequenceUtils {
        public static <T> void swap(T[] data, int i, int j) {
            T tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

    }
}

