#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

vector<vector<P>> make_pair(vector<bool> &used_list){
    vector<vector<P>> ret_list;
    int det1 = -1, det2 = -1;
    for(int i = 0; i < used_list.size(); i++){
        if(used_list[i]){
            continue;
        }
        used_list[i] = true;
        det1 = i;
        break;
    }
    if(det1 == -1){
        vector<P> ret_tmp_list;
        ret_list.emplace_back(ret_tmp_list);
        return ret_list;
    }

    for(int i = det1+1; i < used_list.size(); i++){
        if(used_list[i]){
            continue;
        }
        used_list[i] = true;
        det2 = i;

        vector<P> ret_tmp_list;
        vector<vector<P>> x_list = make_pair(used_list);
        for(auto x: x_list){
            x.emplace_back(P(det1, det2));
            ret_list.emplace_back(x);
        }
        used_list[det2] = false;
    }
    if(det2 == -1){
        vector<P> ret_tmp_list;
        ret_tmp_list.emplace_back(P(det1, -1));
        ret_list.emplace_back(ret_tmp_list);
    }

    used_list[det1] = false;
    return ret_list;
}


int main(){
    char s[12][12];
    char s_tmp[12][12];
    int H, W;
    cin >> H >> W;

    vector<bool> used_list;
    for(int i = 0; i < H; i++){
        used_list.push_back(false);
    }
    vector<vector<P>> pair_list_list;
    if(H % 2 == 0) {
        pair_list_list = make_pair(used_list);
    }
    else{
        for(int i = 0; i < H; i++){
            used_list[i] = true;
            vector<vector<P>> pair_list_list_tmp = make_pair(used_list);
            fill(used_list.begin(), used_list.end(), false);
            for(auto pair_list: pair_list_list_tmp){
                pair_list.emplace_back(P(i, -1));
                pair_list_list.emplace_back(pair_list);
            }
        }
    }
    // cout << pair_list_list.size() << endl;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char c; cin >> c;
            s[i][j] = c;
        }
    }


    bool res = false;
    for(auto pair_list: pair_list_list){
        int index = 0;
        for(auto p: pair_list){
            for(int i = 0; i < W; i++){
                s_tmp[index][i] = s[p.fs][i];
            }
            if(p.sc != -1){
                for(int i = 0; i < W; i++){
                    s_tmp[H-index-1][i] = s[p.sc][i];
                }
            }
            index++;
        }
        vector<bool> used_list2;
        for(int i = 0; i < W; i++){
            used_list2.push_back(false);
        }

        for(int j1 = 0; j1 < W; j1++){
            int exi = -1;
            if(used_list2[j1]){
                continue;
            }
            for(int j2 = j1+1; j2 < W; j2++){
                if(used_list2[j2]){
                    continue;
                }
                bool match = true;
                for(int i = 0; i < H; i++){
                    if(s_tmp[i][j1] != s_tmp[H-i-1][j2]){
                        match = false;
                        break;
                    }
                }
                if(match){
                    exi = j2;
                    break;
                }
            }
            if(exi != -1){
                used_list2[j1] = true;
                used_list2[exi] = true;
            }
        }

        int false_num = 0;
        for(int i = 0; i < W; i++){
            if(!used_list2[i]){
                false_num++;
            }
        }
        bool res2 = true;
        if(false_num == 1){
            for(int j = 0; j < W; j++){
                if(!used_list2[j]){
                    for(int i = 0; i < H; i++){
                        if(s_tmp[i][j] != s_tmp[H-i-1][j]){
                            res2 = false;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        else if(false_num > 1){
            res2 = false;
        }

        if(res2){
            // cout << false_num << endl;
            res = true;
            break;
        }
    }

    if(res){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }


    return 0;

}


Measured memory_bytes: 1280