# Should not work in the time limit. N, M = list(map(int, input().split())) inc_dec = [] for _ in range(M): inc_dec.append(list(map(int, input().split()))) cum_sum = [[0] * (N+1) for _ in range(M+1)] for i in range(M): for j in range(N): cum_sum[i+1][j+1] = cum_sum[i][j+1] + cum_sum[i+1][j] - cum_sum[i][j] + inc_dec[i][j] for end_y in range(1, M+1): for start_x in range(N): for end_x in range(start_x+1, N+1): if cum_sum[end_y][end_x] - cum_sum[end_y][start_x] == 777: print('YES') exit() print('NO')