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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const ll MAX = 4e6;
const ld EPS = 1e-7;
const ld INF = 1e9;
ll dp[MAX];

int main () {
    ios_base::sync_with_stdio(0);
    ll t;
    cin >> t;

    while (t--) {
        ll n;
        cin >> n;
        ld l, a, b;
        ld sr1, sr2;
        ld m1, m2, mi1, mi2;
        m1 = m2 = -INF;
        mi1 = mi2 = INF;
        ld ile = 0;
        sr1 = sr2 = 0;
        for (int i = 0; i < n; ++i) {
            cin >> l >> a >> b;
            sr1 += l * a;
            sr2 += l * b;
            ile += l;
            mi1 = min(a, mi1);
            m1 = max(a, m1);
            mi2 = min(b, mi2);
            m2 = max(b, m2);
        }
        sr1 /= ile;
        sr2 /= ile;

        if (abs(sr1 - sr2) < EPS && m2 <= m1 && mi2 >= mi1) puts("TAK");
        else puts("NIE");
    }
}
/**
1
76
164 202 493
747 580 353
752 426 828
528 14 698
246 595 444
815 823 550
810 275 327
672 203 557
245 487 784
871 292 190
838 768 45
778 43 853
718 475 18
678 796 628
185 761 935
289 353 413
441 20 482
914 432 750
483 61 936
691 229 15
495 67 60
366 814 786
88 929 417
907 926 148
1 31960 1
460 302 436
482 138 516
614 900 628
729 298 271
375 654 420
216 782 939
594 494 615
297 259 236
772 701 408
451 857 791
400 183 482
61 768 194
148 342 190
985 933 829
837 763 120
663 535 737
722 42 980
973 509 467
455 7 148
218 346 71
790 337 243
182 788 586
972 860 991
699 267 999
239 267 473
736 47 207
358 871 515
256 465 810
309 645 810
235 559 442
39 399 701
259 57 465
325 829 522
135 521 669
925 663 712
769 392 292
348 396 453
343 290 498
494 41 91
348 457 362
489 520 447
728 780 262
760 138 860
190 788 361
120 548 49
744 930 432
384 728 329
779 33 650
998 888 88
395 720 166
567 466 710
**/