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
#include <bits/stdc++.h>
using namespace std;

const int N = 13;

int n, m, c[N], p[N], q[N];
char b[N][N];

void Y(){ puts("YES"); exit(0); }

int g(string &s, string &t){
    string u = t;
    reverse(u.begin(), u.end());
    return (s == u);
}

void f(int x, int y){
    if(count(c, c + n, 1) == n){
        string s[N];
        map<string, int> mp;        
        for(int i = x - 1; i >= 0; i--){
            for(int j = 0; j < m; j++) s[j] += b[q[i]][j];
        }
        for(int i = (n & 1); i < x; i++){
            for(int j = 0; j < m; j++) s[j] += b[p[i]][j];
        }
        for(int i = 0; i < m; i++) mp[s[i]]++;
        for(int i = m * !(m & 1); i < m + !(m & 1); i++){
            if(i < m && !g(s[i], s[i])) continue;
            if(i < m) mp[s[i]]--;
            int t = 1;
            for(int j = 0; j < m; j++){
                if(i == j) continue;
                string u = s[j];
                reverse(u.begin(), u.end());
                if(s[j] == u) if(mp[u] & 1){ t = 0; break; }
                if(mp[u] != mp[s[j]]){ t = 0; break; }
            }
            if(i < m) mp[s[i]]++;
            if(t) Y();
        }
        return;
    }
    for(; y >= 0 && c[y]; y++);
    if(y >= 0) c[y] = 1;
    p[x] = y;
    for(int i = y + 1; i < n; i++){
        if(c[i]) continue;
        c[i] = 1; q[x] = i;
        f(x + 1, y + 1);
        c[i] = 0;
    }
    if(y >= 0) c[y] = 0;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%s", b[i]);
    f(0, -(n & 1));
    puts("NO");
}