#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; #define MOD 1000000007 // 10^9 + 7 #define INF 1000000000 // 10^9 #define LLINF 1LL<<60 int a[1001][1001]; bool C(vector train) { int sum = 0; // left <= i < right を満たすtrain[i]の和 int left = 0, right = 0; bool flag = false; while(!flag && left < train.size()) { while (sum < 777 && right < train.size()) { sum += train[right]; right++; } if (sum == 777) flag = true; sum -= train[left]; left++; } return flag; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) cin >> a[i][j]; } vector V(N); bool ans = false; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) V[j] += a[i][j]; if (C(V)) ans = true; } if (ans) cout << "YES" << endl; else cout << "NO" << endl; return 0; }