# 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()))) # num_passengers[i][j]: i駅時点でのj番目の車両の乗客数 num_passengers = [[0] * N for _ in range(M)] # cum_sum[i][j+1]: i駅の時点での、0番目の車両からj番目の車両までの総乗客数 cum_sum = [[0] * (N+1) for _ in range(M)] for j in range(N): num_passengers[0][j] = inc_dec[0][j] cum_sum[0][j+1] = cum_sum[0][j] + num_passengers[0][j] for i in range(M): for j in range(N): num_passengers[i][j] = num_passengers[i-1][j] + inc_dec[i][j] cum_sum[i][j+1] = cum_sum[i][j] + num_passengers[i][j] for station in range(M): for start_i in range(N): target = 777 + cum_sum[station][start_i] # 以下のようになるようなxを求める # cum_sum[station][x] - cum_sum[station][start_i] == 777 # xの候補の範囲 l, r = start_i+1, N while l < r: m = (l + r) // 2 if cum_sum[station][m] == target: print('YES') exit() if cum_sum[station][m] < target: l = m + 1 else: r = m - 1 if cum_sum[station][l] == target: print('YES') exit() print('NO')