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;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<char>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli h,w;
mat m,t,o;
map<string,lli> mp;
map<string,lli> tp;
lli c;

bool special_check(){
  if(mp.size() == 1 && tp.size() == 1){
    for(auto x : mp){
      for(auto y : tp){
        if(x.first == y.first){
          for(lli i = 0;i < h;i++){
            for(lli j = 0;j < w;j++){
              // cout << i << " " << j << " " << h-i-1 << " " << w-j-1 <<  " " << m[i][j] << " " << m[h-i-1][w-j-1] << endl;
              if(o[i][j] != o[h-i-1][w-j-1]) return false;
            }
          }
        }
      }
    }
  }
  return true;

}


int main(){
  cin >> h >> w;
  o = m = mat(h,vector<char>(w));
  t = mat(w,vector<char>(h));
  for(lli i = 0;i < h;i++){
    string s;
    cin >> s;
    for(lli j = 0;j < w;j++){
      o[i][j] = m[i][j] = s[j];
      t[j][i] = s[j];
    }
  }




   c = 0;
   for(lli i = 0;i < h;i++){
     sort(m[i].begin(),m[i].end());
     mp[string(m[i].begin(),m[i].end())]++;
   }
   for(auto x : mp){
     if(x.second%2 == 1) c++;
   }
   if(c > 1){
     cout << "NO" << endl;
     return 0;
   }


   c = 0;
   for(lli j = 0;j < w;j++){
     sort(t[j].begin(),t[j].end());
     tp[string(t[j].begin(),t[j].end())]++;
   }
   for(auto x : tp){
     if(x.second%2 == 1) c++;
   }
   if(c > 1){
     cout << "NO" << endl;
     return 0;
   }

  if(special_check() == false){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;


}
