#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int W,H;
    cin>>W>>H;

    vector<vint>a,b;

    rep(i,H){
        vint v(W);
        rep(j,W)cin>>v[j];

        int c=count(all(v),0);
        if(c==W/2)a.pb(v);
        else if(c==(W+1)/2){
            b.pb(v);
        }
        else{
            cout<<"no"<<endl;
            return 0;
        }
    }

    if(W%2==0){
        map<vint,int>m;
        rep(i,a.size())m[a[i]]++;
        if(m.size()!=2||abs(m.begin()->se-m.rbegin()->se)>1){
            cout<<"no"<<endl;
            return 0;
        }

        vint x=m.begin()->fi;
        vint y=m.rbegin()->fi;

        rep(i,x.size())if(x[i]==y[i]){
            cout<<"no"<<endl;
            return 0;
        }
        cout<<"yes"<<endl;
        return 0;
    }

    if(abs((int)a.size()-(int)b.size())>1){
        cout<<"no"<<endl;
        return 0;
    }

    sort(all(a));a.erase(unique(all(a)),a.end());
    sort(all(b));b.erase(unique(all(b)),b.end());
    if(a.size()!=1||b.size()!=1){
        cout<<"no"<<endl;
        return 0;
    }

    rep(i,a[0].size())if(a[0][i]==b[0][i]){
        cout<<"no"<<endl;
        return 0;
    }
    cout<<"yes"<<endl;
    return 0;
}