1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
#define MAX_N 100021
#define INF 2147483647
using namespace std;

int t, n, min_w, max_w, min_h, max_h;
bool majoryzuje;

struct lustro
{
    int w1, w2, h1, h2;
} firmy[MAX_N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> t;
    for(int lzd=0; lzd<t; ++lzd)
    {
        majoryzuje=false;
        min_w=min_h=INF; max_w=max_h=-INF;
        cin >> n;
        for(int i=1; i<=n; ++i)
        {
            cin >> firmy[i].w1 >> firmy[i].w2 >> firmy[i].h1 >> firmy[i].h2;
            min_w=min(min_w, firmy[i].w1); min_h=min(min_h, firmy[i].h1);
            max_w=max(max_w, firmy[i].w2); max_h=max(max_h, firmy[i].h2);
        }
        for(int i=1; i<=n; ++i)
            if(firmy[i].w1==min_w && firmy[i].w2==max_w && firmy[i].h1==min_h && firmy[i].h2==max_h) majoryzuje=true;
        if(majoryzuje) cout << "TAK" << endl;
        else cout << "NIE" << endl;
    }
    return 0;
}