#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; bool flag = false; vector num(N, 0); for (int i = 0; i < N; i++) { cin >> num[i]; } vector sum(N, 0); for (int i = 0; i < N; i++) { sum[i] = (i == 0 ? 0 : sum[i - 1]) + num[i]; } for (int i = 0; i < N; i++) { const ll obj = 777 + (i == 0 ? 0 : sum[i - 1]); if (upper_bound(sum.begin() + i, sum.end(), obj) - lower_bound(sum.begin() + i, sum.end(), obj) > 0) { flag = true; } } for (int i = 1; i < M; i++) { for (int j = 0; j < N; j++) { ll a; cin >> a; num[j] += a; sum[j] = (j == 0 ? 0 : sum[j - 1]) + num[j]; } for (int i = 0; i < N; i++) { const ll obj = 777 + (i == 0 ? 0 : sum[i - 1]); if (upper_bound(sum.begin() + i, sum.end(), obj) - lower_bound(sum.begin() + i, sum.end(), obj) > 0) { flag = true; } } } cout << (flag ? "YES" : "NO") << endl; return 0; }