understudies went to the primary gathering of the Berland SU programming course (n is even). All understudies will be partitioned into two gatherings. Each gathering will go to precisely one example every week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days picked for the gatherings
correct and detailed answer will be upvoted else downvoted. Output screenshot also required.
understudies went to the primary gathering of the Berland SU
Every understudy has filled an overview where they told which days of the week are advantageous for them to go to an illustration, and which are not.
Your assignment is to decide whether it is feasible to pick two unique week days to plan the examples for the gathering (the main gathering will go to the illustration on the primary picked day, the subsequent gathering will go to the example on the second picked day), and gap the understudies into two gatherings, so the gatherings have equivalent sizes, and for every understudy, the picked illustration day for their gathering is advantageous.
Input : The primary line contains a solitary integer t (1≤t≤104) — the number of testcases. Then, at that point, the portrayals of t testcases follow. The primary line of each testcase contains one integer n (2≤n≤1000) — the number of understudies.
The I-th of the following n lines contains 5 integers, every one of them is 0 or 1. Assuming the j-th integer is 1, the I-th understudy can go to the examples on the j-th day of the week. In the event that the j-th integer is 0, the I-th understudy can't go to the illustrations on the j-th day of the week. Extra requirements on the input: for every understudy, somewhere around one of the times of the week is advantageous, the absolute number of understudies over all testcases doesn't surpass 105.
Output :For each testcase print a reply. In case it's feasible to partition the understudies into two gatherings of equivalent sizes and pick various days for the gatherings so every understudy can go to the illustration in the picked day of their gathering, print "YES" (without quotes). In any case, print "NO" (without quotes).
Step by step
Solved in 4 steps with 1 images