import numpy as np v, d = map(int, input().split()) e = np.array([list(map(int, list(input()))) for _ in range(v)], dtype=np.int64) e_d = np.linalg.matrix_power(e, d) print("Yes" if len(e_d[e_d.nonzero()]) == v * v else "No")