description: n students attended the first meeting of the Berland SU programming course (n is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.
  
  Each student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. 
  
  Your task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.
  
  Then the descriptions of t testcases follow.
  
  The first line of each testcase contains one integer n (2 ≤ n ≤ 1 000) — the number of students.
  
  The i-th of the next n lines contains 5 integers, each of them is 0 or 1. If the j-th integer is 1, then the i-th student can attend the lessons on the j-th day of the week. If the j-th integer is 0, then the i-th student cannot attend the lessons on the j-th day of the week. 
  
  Additional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed 10^5.
  
  Output
  
  For each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print "YES" (without quotes). Otherwise, print "NO" (without quotes). 
  
  Example
  
  Input
  
  
  2
  4
  1 0 0 1 0
  0 1 0 0 1
  0 0 0 1 0
  0 1 0 1 0
  2
  0 0 0 1 0
  0 0 0 1 0
  
  
  Output
  
  
  YES
  NO
  
  Note
  
  In the first testcase, there is a way to meet all the constraints. For example, the first group can consist of the first and the third students, they will attend the lessons on Thursday (the fourth day); the second group can consist of the second and the fourth students, and they will attend the lessons on Tuesday (the second day).
  
  In the second testcase, it is impossible to divide the students into groups so they attend the lessons on different days.
solution: 
  import java.io.*;
  import java.util.*;
  
  public class Solution {
  
      /* -------------------------------------- Main Start ----------------------------------- */
      
      public static void main(String[] args) throws IOException {
          FastReader fs = new FastReader();
          StringBuilder sb = new StringBuilder();
          int t = Integer.parseInt(fs.nextLine());
          while (t-- > 0) {
              int n = fs.nextInt();
              int[][] student = new int[n][5];
              for(int i = 0; i < n; i++){
                  student[i] = fs.II(5);
              }
              
              boolean isPoss = false;
              for(int i = 0; i < 5; i++){
                  Set<Integer> set = new HashSet<>();
                  int count = 0;
                  for(int j = 0; j < n; j++){
                     if(student[j][i] == 1) {
                         set.add(j);
                         count++;
                     }
                     
                  }
                  
                  if(count < n / 2) continue;
                  
                  for(int j = 0; j < 5; j++){
                      if(j == i) continue;
                      int next = 0;
                      int both = 0;
                      for(int k = 0; k < n; k++){
                          if(set.contains(k) && student[k][j] == 1){
                              both++;
                          }
                          if(set.contains(k)) continue;
                          if(student[k][j] == 0) break;
                          next++;
                      }
  //                    System.out.println(i + ", " + j + " => " + count + ", " + next + " ," + both);
                      if(next + count == n){
                          if(next == n / 2 && count == n / 2){
                              isPoss = true;
                              break;
                          }
                          else if(count > next){
                              int req = (n / 2) - next;
                              both = both / 2;
                              if(req <= both){
                                  isPoss = true;
                                  break;
                              }
                          }
                      }
                  }
                  if(isPoss) break;
              }
              if(isPoss) System.out.println("YES");
              else System.out.println("NO");
          }
      }
    
      /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  
        StringBuilder sb = new StringBuilder();
        sb.append(x + "\n");
      
        Collections.sort(arr, (a, b) -> Integer.compare(a[0], b[0]))
        arr.toArray(new int[arr.size()][])
      
       */
      private static final int MOD_1 = 1000000000 + 7;
  
      static class FastReader {
  
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() throws IOException {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String next() throws IOException {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          double nextDouble() throws IOException {
              return Double.parseDouble(next());
          }
  
          String nextLine() throws IOException {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
  
          /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
          void printArray(int[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void printArray(String[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void printArray(long[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void print(int data) {
              System.out.println(data);
          }
  
          void print(String data) {
              System.out.println(data);
          }
  
          void print(long data) {
              System.out.println(data);
          }
  
          int[] II(int n) throws IOException {
              int[] d = new int[n];
              String[] arr = nextLine().split(" ");
              for (int i = 0; i < n; i++) {
                  d[i] = Integer.parseInt(arr[i]);
              }
  
              return d;
          }
  
          String[] IS(int n) throws IOException {
              return nextLine().split(" ");
          }
  
          long[] IL(int n) throws IOException {
              long[] d = new long[n];
              String[] arr = nextLine().split(" ");
              for (int i = 0; i < n; i++) {
                  d[i] = Long.parseLong(arr[i]);
              }
              return d;
          }
  
          public long gcd(long a, long b) {
              if (a == 0) {
                  return b;
              }
              return gcd(b % a, a);
          }
  
          public long power(long x, long y, long p) {
              long res = 1;
              x = x % p;
              if (x == 0) {
                  return 0;
              }
  
              while (y > 0) {
                  if ((y & 1) == 1) {
                      res = (res * x) % p;
                  }
                  y = y >> 1;
                  x = (x * x) % p;
              }
              return res;
          }
  
          void sieveOfEratosthenes(boolean prime[], int size) {
              Arrays.fill(prime, true);
              prime[0] = prime[1] = false;
              prime[2] = true;
  
              for (int p = 2; p * p < size; p++) {
                  if (prime[p] == true) {
                      for (int i = p * p; i < size; i += p) {
                          prime[i] = false;
                      }
                  }
              }
          }
  
          public long fact(long n) {
              long ans = 1;
              for (int i = 2; i <= n; i++) {
                  ans = (ans * i) % MOD_1;
              }
              return ans;
          }
  
          public long lcm(long a, long b) {
              return (a * b) / gcd(a, b);
          }
  
          public int log2(int N) {
              int result = (int) (Math.log(N) / Math.log(2));
              return result;
          }
  
          // find first element in the arr that is equal to the x. 
          // If x is not present in arr then it will return first element that is greater than x
          // It return arr.size() if all element are smaller than x
          public int lowerBound(int[] arr, int x) {
              int low = 0, high = arr.length, mid = -1;
  
              while (low < high) {
                  mid = (low + high) / 2;
  
                  if (arr[mid] >= x) {
                      high = mid;
                  } else {
                      low = mid + 1;
                  }
              }
  
              return low;
          }
  
          // find first element in the arr that is greater than x. 
          // It return arr.size() if all element are smaller than x
          public int upperBound(int[] arr, int x) {
              int low = 0, high = arr.length, mid = -1;
  
              while (low < high) {
                  mid = (low + high) / 2;
  
                  if (arr[mid] > x) {
                      high = mid;
                  } else {
                      low = mid + 1;
                  }
              }
  
              return low;
          }
  
      }
  
  }
  