#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ valid(int *, int);
int main() {
  int a[100000] = {};
  int t = 0, n = 0, b = 0;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d", &n);
    for (int j = 0; j < n; ++j)
      scanf("%d", a + j);
    for (int j = 0; j < n; ++j) {
      scanf("%d", &b);
      a[j] = b - a[j];
    }
    printf("%s\n", valid(a, n) ? "TAK" : "NIE");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x61a90(%rbp),%rdi
xor    %esi,%esi
mov    $0x61a80,%edx
call   1040 <memset@plt>
movl   $0x0,-0x61a94(%rbp)
movl   $0x0,-0x61a98(%rbp)
movl   $0x0,-0x61a9c(%rbp)
lea    0xe76(%rip),%rdi
lea    -0x61a94(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x61aa0(%rbp)
mov    -0x61aa0(%rbp),%eax
cmp    -0x61a94(%rbp),%eax
jge    12c6 <main+0x186>
lea    0xe47(%rip),%rdi
lea    -0x61a98(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x61aa4(%rbp)
mov    -0x61aa4(%rbp),%eax
cmp    -0x61a98(%rbp),%eax
jge    1216 <main+0xd6>
lea    -0x61a90(%rbp),%rsi
movslq -0x61aa4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe03(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x61aa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa4(%rbp)
jmp    11cf <main+0x8f>
movl   $0x0,-0x61aa8(%rbp)
mov    -0x61aa8(%rbp),%eax
cmp    -0x61a98(%rbp),%eax
jge    127b <main+0x13b>
lea    0xdc7(%rip),%rdi
lea    -0x61a9c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x61a9c(%rbp),%ecx
movslq -0x61aa8(%rbp),%rax
sub    -0x61a90(%rbp,%rax,4),%ecx
movslq -0x61aa8(%rbp),%rax
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x61aa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa8(%rbp)
jmp    1220 <main+0xe0>
lea    -0x61a90(%rbp),%rdi
mov    -0x61a98(%rbp),%esi
call   1050 <valid@plt>
mov    %rax,%rcx
lea    0xd74(%rip),%rsi
lea    0xd69(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xd56(%rip),%rdi
call   1030 <printf@plt>
mov    -0x61aa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa0(%rbp)
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a98,%rsp
lea    0x10(%rsp),%r14
xor    %r15d,%r15d
mov    $0x61a80,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe79(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    125a <main+0x11a>
lea    0xe5d(%rip),%rbx
lea    0xc(%rsp),%r12
jmp    11e4 <main+0xa4>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <valid@plt>
test   %rax,%rax
lea    0xe45(%rip),%rsi
lea    0xe42(%rip),%rax
cmove  %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r15d
cmp    0x8(%rsp),%r15d
jge    125a <main+0x11a>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11b0 <main+0x70>
mov    %r14,%rbp
xor    %r13d,%r13d
nop
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
movslq 0x4(%rsp),%rsi
add    $0x4,%rbp
cmp    %rsi,%r13
jl     1200 <main+0xc0>
test   %esi,%esi
jle    11b0 <main+0x70>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
sub    0x10(%rsp,%rbp,4),%eax
mov    %eax,0x10(%rsp,%rbp,4)
add    $0x1,%rbp
movslq 0x4(%rsp),%rsi
cmp    %rsi,%rbp
jl     1230 <main+0xf0>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x61a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c"TAK\00"
@.str.3 = [4 x i8] c"NIE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [100000 x i32]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %6
br label %11
11: ; preds = %57, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %60
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %7
br label %17
17: ; preds = %27, %15
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 0
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %17
30: ; preds = %17
store i32 0, i32* %8
br label %31
31: ; preds = %46, %30
%32 = load i32, i32* %8
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%37 = load i32, i32* %5
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = sub nsw i32 %37, %41
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 %44
store i32 %42, i32* %45
br label %46
46: ; preds = %35
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %31
49: ; preds = %31
%50 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 0
%51 = load i32, i32* %4
%52 = call i64 @valid(i32* %50, i32 %51)
%53 = icmp ne i64 %52, 0
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %55)
br label %57
57: ; preds = %49
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %11
60: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c"TAK\00"
@.str.3 = [4 x i8] c"NIE\00"
define i32 @main() {
%1 = alloca [100000 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [100000 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 0
br label %15
14: ; preds = %30, %0
ret i32 0
15: ; preds = %12, %30
%16 = phi i32 [ 0, %12 ], [ %36, %30 ]
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %22, label %30
20: ; preds = %22
%21 = icmp sgt i32 %27, 0
br i1 %21, label %39, label %30
22: ; preds = %15, %22
%23 = phi i64 [ %26, %22 ], [ 0, %15 ]
%24 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %24)
%26 = add nuw nsw i64 %23, 1
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %22, label %20
30: ; preds = %39, %15, %20
%31 = phi i32 [ %27, %20 ], [ %18, %15 ], [ %47, %39 ]
%32 = call i64 @valid(i32* %13, i32 %31)
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = add nuw nsw i32 %16, 1
%37 = load i32, i32* %2
%38 = icmp slt i32 %36, %37
br i1 %38, label %15, label %14
39: ; preds = %20, %39
%40 = phi i64 [ %46, %39 ], [ 0, %20 ]
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%42 = load i32, i32* %4
%43 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %40
%44 = load i32, i32* %43
%45 = sub nsw i32 %42, %44
store i32 %45, i32* %43
%46 = add nuw nsw i64 %40, 1
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %39, label %30
}