// yukicoder: No.607 開通777年記念 // 2019.5.6 bal4u #include #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() // 整数の入力(負数対応) { int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void outs(char *s) { while (*s) pc(*s++); } #define G 777 int a[1005]; int main() { int i, j, k, N, M, s; N = in(), M = in(); while (M--) { for (i = 0; i < N; i++) a[i] += in(); j = k = 0, s = 0; while (j < N) { while (j < N && s < G) s += a[j++]; if (s == G) goto YES; s -= a[k++]; } } outs("NO\n"); return 0; YES:outs("YES\n"); return 0; }