There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.

Snuke can apply the following operation to this grid any number of times:

* Choose two different rows and swap them. Or, choose two different columns and swap them.



Snuke wants this grid to be symmetric. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.

Determine if Snuke can achieve this objective.

Constraints

* 1 \leq H \leq 12
* 1 \leq W \leq 12
* |S_i| = W
* S_i consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


H W
S_1
S_2
:
S_H


Output

If Snuke can make the grid symmetric, print `YES`; if he cannot, print `NO`.

Examples

Input

2 3
arc
rac


Output

YES


Input

3 7
atcoder
regular
contest


Output

NO


Input

12 12
bimonigaloaf
faurwlkbleht
dexwimqxzxbb
lxdgyoifcxid
ydxiliocfdgx
nfoabgilamoi
ibxbdqmzxxwe
pqirylfrcrnf
wtehfkllbura
yfrnpflcrirq
wvcclwgiubrk
lkbrwgwuiccv


Output

YES
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/


int n,m;;
char maze[1005][1005];
int a[1005];
bool vis[1005];
int ans=0;
bool v2[1005];
bool check()
{
	memset(v2,0,sizeof(v2));
	bool used=(m&1);
	for(int i=1;i<=m;i++)
	{
		if(!v2[i])
		{
			bool ok=false;
			for(int j=i+1;j<=m;j++)
			{
				if(!v2[j])
				{
					bool ok2=true;
					for(int k=1;k<=n;k++)
					{
						if(maze[a[k]][i]!=maze[a[n-k+1]][j])
						{
							ok2=false;
						}
					}
					if(ok2)
					{
						v2[j]=true;
						ok=true;
						break;
					}
				}
			}
			if(!ok)
			{
				if(used)
				{
					bool ok2=true;
					for(int k=1;k<=n;k++)
					{
						if(maze[a[k]][i]!=maze[a[n-k+1]][i])
							ok2=false;
					}
					if(ok2)
					{
						used=false;
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
		}
	}
	return true;
}
void dfs(int x,int pos,bool odd)
{
	if(ans)
		return;
	if(x>n)
	{
		ans=check();
		return;
	}
	if(vis[x])
	{
		dfs(x+1,pos,odd);
		return;
	}
	for(int i=x+1;i<=n;i++)
	{
		if(!vis[i])
		{
			a[pos]=i;
			a[n-pos+1]=x;
			vis[i]=true;
			dfs(x+1,pos+1,odd);
			vis[i]=false;
		}
	}
	if(odd)
	{
		a[(n>>1)+1]=x;
		dfs(x+1,pos,0);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>maze[i][j];
		}
	}
	dfs(1,1,n%2);
	if(ans)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}
