#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
 	freopen("chocolate.in", "r", stdin);
  	freopen("chocolate.out", "w", stdout);
  	int n, m;
  	scanf("%d%d", &n, &m);
  	int bar[n][m];
  	for(int i = 0; i < n; i++)
  		for(int j = 0; j < m; j++)
  			scanf("%d", &bar[i][j]);
  	for(int i = 0; i < n - 1; i++)
  	{
  	  	bool breaks = true;
  	 	for(int j = 0; j < m; j++)
  	    	if (bar[i][j] == bar[i + 1][j])
  	    	{
  	    		breaks = false;
  	    		break;
  	    	}
	  	if (breaks)
	  	{
	  		cout << "Yes" << endl;
	  		return 0;
	  	}	
  	}
  	for(int j = 0; j < m - 1; j++)
  	{
  	  	bool breaks = true;
  	 	for(int i = 0; i < n; i++)
  	    	if (bar[i][j] == bar[i][j + 1])
  	    	{
  	    		breaks = false;
  	    		break;
  	    	}
	  	if (breaks)
	  	{
	  		cout << "Yes" << endl;
	  		return 0;
	  	}	
  	}
  	cout << "No" << endl;
}

