import numpy as np v, d = map(int, input().split()) e = np.array([list(map(int, input())) for _ in range(v)], dtype='bool') now = np.identity(v, dtype='bool') while d: if d & 1: now = np.dot(now, e) e = np.dot(e, e) d >>= 1 if all(all(r) for r in e): print('Yes') else: print('No')