#P1598B. Groups

    ID: 6139 Type: RemoteJudge 4000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>brute forceimplementation*1000

Groups

No submission language available for this problem.

Description

nn students attended the first meeting of the Berland SU programming course (nn 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.

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

Then the descriptions of tt testcases follow.

The first line of each testcase contains one integer nn (2n10002 \le n \le 1\,000) — the number of students.

The ii-th of the next nn lines contains 55 integers, each of them is 00 or 11. If the jj-th integer is 11, then the ii-th student can attend the lessons on the jj-th day of the week. If the jj-th integer is 00, then the ii-th student cannot attend the lessons on the jj-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 10510^5.

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).

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

Then the descriptions of tt testcases follow.

The first line of each testcase contains one integer nn (2n10002 \le n \le 1\,000) — the number of students.

The ii-th of the next nn lines contains 55 integers, each of them is 00 or 11. If the jj-th integer is 11, then the ii-th student can attend the lessons on the jj-th day of the week. If the jj-th integer is 00, then the ii-th student cannot attend the lessons on the jj-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 10510^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).

Samples

Sample Input 1

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

Sample Output 1

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.