blob: f3f9c6027119505d7c8d984d12c12c40c6f7950f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/env python2
from operator import not_, sub
from sys import stdin
for _ in xrange(int(stdin.readline())):
n = int(stdin.readline())
a = map(int, stdin.readline().split())
b = map(int, stdin.readline().split())
c = map(sub, b, a)
for i in xrange(n - 2):
if c[i] < 0:
print 'NIE'
break
c[i + 1] -= c[i] * 2
c[i + 2] -= c[i] * 3
else:
if n < 3:
print 'NIE' if any(c) else 'TAK'
else:
print 'TAK' if c[-2] == c[-1] == 0 else 'NIE'
|