import numpy as np import sys def solve(): v, d = map(int, input().split()) e = np.array([list(map(int, sys.stdin.readline().rstrip())) for _ in range(v)], dtype='bool') now = np.identity(v, dtype='bool') while d: if d % 2: now = np.dot(now, e) e = np.dot(e, e) d //= 2 if all(all(r) for r in now): print('Yes') else: print('No') solve()