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>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

char c[20][20];
int h, w, d[20], e[20];

bool solve(int x) {
    if(x >= w) return true;
    if(~e[x]) return solve(x + 1);
    int t = 0;
    FOR(i, x, w) t ^= !~e[i];
    FOR(i, x, w) if(!~e[i]) {
        e[x] = i;
        e[i] = x;
        bool ok = true;
        rep(j, h) if(c[j][x] != c[d[j]][i]) ok = false;
        if(i == x && ok && t && solve(x + 1)) return true;
        if(i != x && ok) return solve(x + 1);
        e[x] = e[i] = -1;
    }
    return false;
}

bool dfs(int x) {
    if(x >= h) return solve(0);
    if(~d[x]) return dfs(x + 1);
    int t = 0;
    FOR(i, x, h) t ^= !~d[i];
    FOR(i, x, h)
    if(!~d[i]) {
        d[x] = i;
        d[i] = x;
        if((t || i != x) && dfs(x + 1)) return true;
        d[x] = d[i] = -1;
    }
    return false;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    memset(d, -1, sizeof(d));
    memset(e, -1, sizeof(e));

    cin >> h >> w;
    rep(i, h) cin >> c[i];

    cout << (dfs(0) ? "YES\n" : "NO\n");

    return 0;
}