#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 1010


int main(void){
int n,m;
vector<int>b;
vector<int>c;
vector<int>d;
vector<int>e;
int bb,cc,dd,ee;
bool ans=true;
bool a[1000][1000];
int x,y,z;
scanf("%d %d",&m,&n);
f(i,n){
f(j,m){
scanf("%d",&x);
if(x==0)a[i][j]=false;
else a[i][j]=true;
}
}
f(i,n){
if(a[i][0])b.push_back(i);
else c.push_back(i);
}
f(i,m){
if(a[0][i])d.push_back(i);
else e.push_back(i);
}
bb=b.size();
cc=c.size();
dd=d.size();
ee=e.size();
if(abs(bb-cc)>1){
printf("no\n");
return 0;
}
if(abs(dd-ee)>1){
printf("no\n");
return 0;
}
f(i,b.size()){
f(j,d.size()){
if(a[b[0]][d[0]]!=a[b[i]][d[j]])ans=false;
}
}
f(i,b.size()){
f(j,e.size()){
if(a[b[0]][e[0]]!=a[b[i]][e[j]])ans=false;
}
}
f(i,c.size()){
f(j,d.size()){
if(a[c[0]][d[0]]!=a[c[i]][d[j]])ans=false;
}
}
f(i,c.size()){
f(j,e.size()){
if(a[c[0]][e[0]]!=a[c[i]][e[j]])ans=false;
}
}
if(a[b[0]][d[0]]!=a[c[0]][e[0]])ans=false;
if(a[b[0]][e[0]]!=a[c[0]][d[0]])ans=false;
if(a[b[0]][d[0]]==a[b[0]][e[0]])ans=false;
if(ans)printf("yes\n");
else printf("no\n");


return 0;
}
