#include <iostream>#include <cstring>#include <cstdio>using namespace std;
const int N = 10;
inline int read()
{
int x = 0, f = 1; char c = getchar();
while (c < '0' || c > '9')
{
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
return x * f;
}
int n, m;
string a[N];
int f[N]; // 排列bool st[N]; // 放置重复元素bool Chk(string a, string b)
{
int t = 0;
for (int i = 0; i < a.size(); i ++ )
if (a[i] != b[i])
{
t ++ ;
if (t == 2) return false;
}
return true;
}
bool chk()
{
for (int i = 1; i < n; i ++ )
if (!Chk(a[f[i]], a[f[i + 1]]))
return false;
return true;
}
void dfs(int u)
{
if (u == n + 1)
{
if (chk()) // 如果全部满足条件,输出 Yes 并结束程序
{
puts("Yes");
exit(0);
}
return;
}
for (int i = 1; i <= n; i ++ )
if (!st[i])
{
f[u] = i, st[i] = true; // 选择这个元素dfs(u + 1); // 搜索
st[i] = false; // 恢复现场
}
}
signed main()
{
n = read(), m = read(); // 读入for (int i = 1; i <= n; i ++ )
cin >> a[i];
dfs(1);
puts("No");
return 0;
}