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
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;
const int INF = 1<<30;
typedef vector<int> Vi;

int main()
{
    ios::sync_with_stdio(0);

    int t; cin >> t;
    while(t--)
    {
        int n; cin >> n;
        Vi w1(n), w2(n), h1(n), h2(n);
        int w_min = INF; int w_max = -INF;
        int h_min = INF; int h_max = -INF;
        for(int i=0; i<n; ++i)
        {
            cin >> w1[i] >> w2[i] >> h1[i] >> h2[i];
            w_min = min(w_min, w1[i]);
            w_max = max(w_max, w2[i]);
            h_min = min(h_min, h1[i]);
            h_max = max(h_max, h2[i]);
        }

        bool istnieje = false;
        for(int i=0; i<n; ++i)
        {
            if(w1[i]==w_min && w2[i]==w_max && h1[i]==h_min && h2[i]==h_max)
            {
                istnieje = true;
                break;
            }
        }
        cout << (istnieje?"TAK\n":"NIE\n");
    }
    cout << flush;
}