#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #include #include #include // clang-format off #define RD(v) int v=0;{int _c,sign=0;for(;;){if(*rp=='-'){sign=1;rp++;}else{_c=*rp++-48;if(_c>=0)v=v*10+_c;else break;}}if(sign)v=-v;} // #define RDULL(v) unsigned long long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} // #define wt_int(var,buf,ptr) while(var){buf[ptr++]=var%10;var/=10;}while(ptr--)putc_unlocked(buf[ptr]+'0',stdout); // clang-format on int a[1000 * 1000]; int b[1001]; #define TARGET 777 int main() { char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll); RD(n) RD(m); int *ap = a; int nm = n * m; for (int i = 0; i < nm; ++i) { RD(t); *ap++ = t; } // b[n] = 1000000000 + 9; for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) b[j] += a[n * i + j]; // for (int j = 0; j < n; ++j) printf("%d ", b[j]); // printf("\n"); int left = 0; int sm = 0; for (int right = 0; right < n; ++right) { int s = sm + b[right]; // printf("%d %d %d = %d + %d\n", i, right, s, sm, b[right]); if (s >= TARGET) { if (s == TARGET) { printf("YES"); exit(0); } if (right == n) break; while (sm + b[right] > TARGET) { sm -= b[left]; left++; } sm += b[right]; } else { sm += b[right]; } } } printf("NO"); exit(0); return 0; // }