import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n, m; scan(n, m); auto jk = new int[](n); auto ps = new int[](n + 1); foreach (i ; 0 .. m) { auto a = readln.split.to!(int[]); jk[] += a[]; foreach (j ; 0 .. n) { ps[j+1] = ps[j] + jk[j]; } debug { writeln(ps); } if (judge(n, ps)) { writeln("YES"); return; } } writeln("NO"); } bool judge(int n, int[] ps) { int l, r; while (r <= n) { int d = ps[r] - ps[l]; if (d == 777) { return true; } else if (d < 777) { r++; } else { l++; } } return false; } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }