Mirror Tender
InterviewTime limit1sMemory limit256 MB
Decide for each test case whether one workshop's width and height ranges contain every other workshop's ranges.
- Level
Easy2 of 10
- Topics
- Intervals
- Solved
- No attempts yet
Problem
Bajtazar's company makes wooden wardrobes with mirrored doors. The company does the woodwork itself and subcontracts the mirrors.
A tender run by the company has just closed. workshops took part, and each one stated the mirror sizes it can produce. Every mirror is a rectangle. A workshop's bid gives the smallest and the largest width it can produce, and the smallest and the largest height. Mirrors cannot be rotated when a wardrobe is built.
If one workshop's bid covers all the other bids, meaning no other bidder offers a mirror size that this workshop cannot produce, that workshop wins the tender. If several workshops submit a covering bid, the one with the lowest price per square centimetre of mirror wins. If no such workshop took part, the review gets complicated and the award is delayed by a lot. Bajtazar wants to avoid a pointless argument, so he asked you to write a program that decides whether some workshop's bid covers all the other bids.
Input
The first line contains one integer (), the number of test cases. Descriptions of the test cases follow.
The first line of each description contains one integer (), the number of mirror workshops that bid in the tender. Each of the next lines contains four integers , , , (, ). That workshop can produce a mirror of every integer width and every integer height with and .
Output
Print exactly lines, one per test case. Line contains TAK if the -th test case has a workshop whose bid covers all the other bids, and NIE otherwise.