#include <iostream>
int main()
{
int n, m;
std::cin >> n;
std::cin >> m;
int **Matrix;
Matrix = new int *[n];
for (int i = 0; i < n; i++)
Matrix[i] = new int[m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
{
std::cin >> Matrix[i][j];
}
bool answer = true;
bool bT = false;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (Matrix[i][j] == 1)
{
bT = true;
int nT = 1;
int mT = 1;
if (i + 1 != n)
{
for (int ii = i + 1; ii < n; ii++)
{
if (Matrix[ii][j] == 1) nT += 1;
else break;
}
}
if (j + 1 != m)
{
for (int jj = j + 1; jj < m; jj++)
{
if (Matrix[i][jj] == 1) mT += 1;
else break;
}
}
for (int ii = 0, it = i; ii < nT; ii++, it++)
{
for (int jj = 0, jt = j; jj < mT; jj++, jt++)
{
if (Matrix[it][jt] != 1) bT = false;
}
}
nT = 1;
mT = 1;
if (i != 0)
{
for (int ii = i - 1; ii >= 0; ii--)
{
if (Matrix[ii][j] == 1) nT += 1;
else break;
}
}
if (j != 0)
{
for (int jj = j - 1; jj >= 0; jj--)
{
if (Matrix[i][jj] == 1) mT += 1;
else break;
}
}
for (int ii = 0, it = i; ii < nT; ii++, it--)
{
for (int jj = 0, jt = j; jj < mT; jj++, jt--)
{
if (Matrix[it][jt] != 1) bT = false;
}
}
if (bT == false) answer = bT;
}
}
}
if (answer) std::cout << "Yes";
else std::cout << "No";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKCmludCBtYWluKCkKewoJaW50IG4sIG07CgkKCXN0ZDo6Y2luID4+IG47CgkKCXN0ZDo6Y2luID4+IG07CgkKCWludCAqKk1hdHJpeDsKCU1hdHJpeCA9IG5ldyBpbnQgKltuXTsKCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJCU1hdHJpeFtpXSA9IG5ldyBpbnRbbV07CgoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJZm9yIChpbnQgaiA9IDA7IGogP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