#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

bool check(const vector< vector<int> > &board, int c) {
    int H = board.size(), W = board[0].size();
    vector<int> rs(H), cs(W);

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int col = (i + j + c) % 2;
            // fprintf(stderr, "%d%c", col, " \n"[j + 1 == W]);
            rs[i] += col;
            cs[j] += col;
        }
    }

    vector<int> rt(H), ct(W);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            rt[i] += board[i][j];
            ct[j] += board[i][j];
        }
    }

    sort(rs.begin(), rs.end());
    sort(cs.begin(), cs.end());
    sort(rt.begin(), rt.end());
    sort(ct.begin(), ct.end());
    return rs == rt and cs == ct;
}

int main() {
    int W, H; cin >> W >> H;
    vector< vector<int> > board(H, vector<int>(W));

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

    bool ok = false;
    ok |= check(board, 0);
    ok |= check(board, 1);

    // row
    set< vector<int> > SR;
    for(int i=0; i<H; i++) {
        vector<int> vec; vec.reserve(W);
        for(int j=0; j<W; j++) {
            vec.emplace_back(board[i][j]);
        }
        SR.emplace(vec);
    }

    // col
    set< vector<int> > SC;
    for(int j=0; j<W; j++) {
        vector<int> vec; vec.reserve(H);
        for(int i=0; i<H; i++) {
            vec.emplace_back(board[i][j]);
        }
        SC.emplace(vec);
    }

    ok &= (SR.size() == 2);
    ok &= (SC.size() == 2);
    
    cout << (ok ? "yes" : "no") << endl;
}

