import sys N, M = map(int, input().split()) sums = [0 for _ in range(N)] nums = [0 for _ in range(N + 1)] done = False for _ in range(M): num = 0 nums[0] = 0 for i, n in enumerate(map(int, input().split())): sums[i] += n nums[i + 1] = sums[i] + num num += sums[i] if done: continue for i in range(N + 1): for j in range(i + 1, N + 1): if nums[j] - nums[i] == 777: done = True if done: print('YES') else: print('NO')