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 using namespace std; int get(){ int w = 0; char c = getchar_unlocked(); while(c < '0' || c > '9')c=getchar_unlocked(); while(c >='0' && c <= '9'){ w*=10; w += c-48; c=getchar_unlocked(); } return w; } int main(){ int n; int m; double s1,s2; int q,a1,a2,il,_,mn1,mn2,m1,m2; n = get(); for (int z = 0; z < n; ++z){ m = get(); il=0; a1=0; mn1 = 1000000; mn2 = 1000000; m1 = 0; m2 = 0; a2=0; for (int i = 0; i < m; ++i){ q = get(); il += q; _=q; q = get(); a1 += _*q; if(q < mn1)mn1 = q; if(q > m1)m1 = q; q = get(); a2 += _*q; if(q < mn2)mn2 = q; if(q > m2)m2 = q; } //cout << m1 << " " << m2 << " / " << mn1 << " " << mn2 << "\n"; if(a1==a2 && m1>=m2 && mn1<=mn2)cout << "TAK\n"; else cout << "NIE\n"; //else cout << "NIE " << a1 << " " << a2 << " " << il << "\n"; } return 0; }