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

#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define int long long
#define ll long long
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()

int n,m;
char a[14][14];
bool ok;
bool seen[14];

void f(int cur){
    bool en = 1;
    if(ok)return;
    for2(i,cur+1,n-cur){
        en = 0;
        for2(j,0,m) swap(a[n-cur-1][j],a[i][j]);
        f(cur+1);
        for2(j,0,m) swap(a[n-cur-1][j],a[i][j]);
    }
    if(en){
        fill(seen,seen+m,0);
        int  cnt = 0;
        for2(i,0,m)if(!seen[i]) for2(k,i+1,m) if(!seen[k]){
            bool same = 1;
            for2(j,0,n) same &= (a[j][i]==a[n-j-1][k]);
            if(same){
                seen[i] = seen[k] = 1;
                cnt += 2;
                break;
            }
        }
        for2(i,0,m) if(!seen[i]){
            bool same = 1;
            for2(j,0,n) same &= (a[j][i]==a[n-j-1][i]);
            if(same){
                cnt++;
            }
            break;
        }
        if(cnt == m ) ok = 1;
    }
}

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for2(i,0,n) for2(j,0,m) cin >> a[i][j];
    for2(i,0,n)if(!ok){
        for2(j,0,m) swap(a[i][j],a[n/2][j]);
        f(0);
        for2(j,0,m) swap(a[i][j],a[n/2][j]);
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}
