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
#include <bits/stdc++.h>

using namespace std;
using ld = long double;

const int inf = 1e9;

struct Herbata {
    ld l, a, b;
};

bool solve() {
    int n;
    cin >> n;
    vector<Herbata> h(n);
    int minia = inf, maksa = 0, minib = inf, maksb = 0;
    for (int i = 0; i < n; ++i) {
        int l, a, b;
        cin >> l >> a >> b;
        minia = min(minia, a);
        minib = min(minib, b);
        maksa = max(maksa, a);
        maksb = max(maksb, b);
    }
    return minia <= minib && maksa >= maksb;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        cout << (solve() ? "TAK" : "NIE") << "\n";
    }
}