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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
using namespace std;

bool oks(vector <vector <int> > lus) {
    long long wMin, wMax, hMin, hMax;
    int poten=0;
    wMin=lus[0][0];
    wMax=lus[0][1];
  //  cout << wMin << " " << wMax << endl;
    for(int i=1; i< lus.size(); i++) {
         //   cout << lus[i][0]<< " " << lus[i][1] << endl;
            if(lus[i][0]<wMin && lus[i][1]>wMax) {
                wMin=lus[i][0];
                wMax=lus[i][1];
                poten=i;
                }
    }
    hMin=lus[poten][2];
    hMax=lus[poten][3];
    for(int i=0; i< lus.size(); i++){
        if(lus[i][2]<hMin || lus[i][3]>hMax)
            return false;
    }


    return true;
}


int main()
{
    int t, n; bool odp=false, ok=true;
    vector <vector <int> > lus;
    long long wMin, wMax, hMin, hMax, ob_wMin, ob_wMax, ob_hMin, ob_hMax;
    cin >> t;
    for (int i=0; i<t; i++) {
        cin >> n;
        lus.clear();
        lus.resize(n);
        for(int j=0; j<n; j++) {
            cin >> wMin >> wMax >> hMin >> hMax;
            lus[j].push_back(wMin );
            lus[j].push_back(wMax );
            lus[j].push_back(hMin );
            lus[j].push_back(hMax );

        }
         if(oks(lus)) cout << "TAK\n"; else cout << "NIE\n";
    }
   // if(odp) cout << "TAK"; else cout << "nie\n";
   // cout << "Hello world!" << endl;
    return 0;
}