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

void solve()
{
    long long sa = 0, sb = 0, l, a, b, n, maa = 0, mia = 1000001, mib = 1000001, mab = 0;
    scanf("%lld", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld%lld%lld", &l, &a, &b);
        sa += l * a;
        sb += l * b;
        mia = min(a, mia);
        maa = max(a, maa);
        mib = min(b, mib);
        mab = max(b, mab);
    }
    if(sa == sb && mab <= maa && mib >= mia) printf("TAK\n");
    else printf("NIE\n");
    return;
}

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) solve();
    return 0;
}