using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; using System.Diagnostics; class Scanner { private readonly char Separator = ' '; private int Index = 0; private string[] Line = new string[0]; public string Next() { if (Index >= Line.Length) { Line = Console.ReadLine().Split(Separator); Index = 0; } var ret = Line[Index]; Index++; return ret; } public int NextInt() { return int.Parse(Next()); } private long NextLong() { return long.Parse(Next()); } } class Program { private int N, M; private int[,] A; private int[] Train; private void Scan() { var sc = new Scanner(); N = sc.NextInt(); M = sc.NextInt(); A = new int[M, N]; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { A[i, j] = sc.NextInt(); } } } public void Solve() { Scan(); Train = new int[N]; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { Train[j] += A[i, j]; } if (C()) { Console.WriteLine("YES"); return; } } Console.WriteLine("NO"); } private bool C() { int left = 0; int right = 0; int sum = 0; for (right = 0; right < N; right++) { if (sum == 777) return true; if (sum > 777) { for (; left <= right; left++) { sum -= Train[left]; if (sum <= 777) break; } } sum += Train[right]; } if (sum > 777) { for (; left <= right; left++) { sum -= Train[left]; if (sum <= 777) break; } } return sum==777; } static public void Main() { new Program().Solve(); } }