#include <iostream>
using namespace std;
 
 
bool BreakRow (int **chocolate, int n, int m){
  for (int i = 0; i < n - 1; i++){
    bool okRow = true;
    for (int j = 0; j < m; j++){
      if(chocolate[i][j] == chocolate [i + 1][j]){okRow = false;break;}
    }
    if (okRow) return true;
  }
  return false;
}
bool BreakColumn (int **chocolate, int n, int m){
  for (int i = 0; i < m - 1; i++){
    bool okColumn = true;
    for (int j = 0; j < n; j++){
      if(chocolate[j][i] == chocolate[j][i + 1]){okColumn = false;break;}
    }
    if (okColumn) return true;
  }
  return false;
}
 
int check (int **chocolate, int n, int m){
  if ( BreakRow(chocolate, n, m) || BreakColumn (chocolate, n, m)) cout<<"Yes";
  else cout<<"No";
}
 
int main() {
  int n, m;
  cin >> n >> m;
  int **chocolate = new int* [n];
  for(int i = 0; i < n; ++i){
    chocolate[i] = new int[m];
  }
  for( int i = 0; i < n;  i++){
    for(int j = 0; j < m; j++){
      cin >> chocolate [i][j];
    }
  }
  check(chocolate, n, m);
  return 0;
}
