#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 *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main() {
  unsigned long long N, T;
  scanf("%Lu", &T);
  while (T--) {
    unsigned long long s = 2;
    unsigned long long i;
    unsigned long long tmp = 0;
    scanf("%Lu", &N);
    while (s < N) {
      if (N % s == 0) {
        int flag = 0;
        for (i = 2; i <= (s / 2); ++i) {
          if (s % i == 0) {
            flag = 1;
            break;
          }
        }
        if (flag == 0)
          tmp = s;
      }
      s++;
    }
    if (tmp == 0) {
      printf("%Lu\n", N);
    } else
      printf("%Lu\n", tmp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     1255 <main+0x135>
movq   $0x2,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe91(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1220 <main+0x100>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
cmp    $0x0,%rdx
jne    120f <main+0xef>
movl   $0x0,-0x34(%rbp)
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
ja     11f8 <main+0xd8>
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
cmp    $0x0,%rdx
jne    11e2 <main+0xc2>
movl   $0x1,-0x34(%rbp)
jmp    11f8 <main+0xd8>
jmp    11e7 <main+0xc7>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11ab <main+0x8b>
cmpl   $0x0,-0x34(%rbp)
jne    120a <main+0xea>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    120f <main+0xef>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1178 <main+0x58>
cmpq   $0x0,-0x30(%rbp)
jne    1240 <main+0x120>
mov    -0x10(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
jmp    1250 <main+0x130>
mov    -0x30(%rbp),%rsi
lea    0xdb9(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea6(%rip),%r14
lea    0x8(%rsp),%r15
mov    $0x2,%r13d
lea    0xe98(%rip),%r12
jmp    1186 <main+0x66>
xchg   %ax,%ax
test   %rax,%rax
cmovne %rax,%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jb     1143 <main+0x23>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rsi
cmp    $0x3,%rsi
jb     1177 <main+0x57>
mov    $0x2,%ecx
xor    %eax,%eax
jmp    11bc <main+0x9c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r8,%rax
add    $0x1,%rcx
cmp    %rsi,%rcx
je     1170 <main+0x50>
mov    %rax,%r8
mov    %rcx,%rdi
shr    %rdi
cmp    $0x3,%rdi
cmovb  %r13,%rdi
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11f0 <main+0xd0>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
jne    11b0 <main+0x90>
jmp    11fb <main+0xdb>
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    11b0 <main+0x90>
mov    %rcx,%rax
cmp    $0x4,%rcx
jb     11b3 <main+0x93>
mov    $0x1,%ebx
sub    %rdi,%rbx
mov    $0x2,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1240 <main+0x120>
mov    %rcx,%rax
xor    %edx,%edx
div    %rdi
test   %rdx,%rdx
jne    124f <main+0x12f>
jmp    11b0 <main+0x90>
xchg   %ax,%ax
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     11b0 <main+0x90>
lea    (%rbx,%rdi,1),%rax
add    $0x1,%rax
add    $0x1,%rdi
cmp    $0x2,%rax
jne    1220 <main+0x100>
mov    %rcx,%rax
jmp    11b3 <main+0x93>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%Lu\00"
@.str.1 = [5 x i8] c"%Lu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%6 = load i64, i64* %2
%7 = add i64 %6, -1
store i64 %7, i64* %2
%8 = icmp eq i64 %6, 0
br i1 %8, label %42, label %9
9: ; preds = %0, %36
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%11 = load i64, i64* %1
%12 = icmp ugt i64 %11, 2
br i1 %12, label %13, label %36
13: ; preds = %9, %29
%14 = phi i64 [ %30, %29 ], [ 0, %9 ]
%15 = phi i64 [ %31, %29 ], [ 2, %9 ]
%16 = lshr i64 %15, 1
%17 = call i64 @llvm.umax.i64(i64 %16, i64 2)
%18 = urem i64 %11, %15
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = icmp ult i64 %15, 4
br i1 %21, label %29, label %25
22: ; preds = %25
%23 = add nuw i64 %26, 1
%24 = icmp eq i64 %26, %17
br i1 %24, label %29, label %25
25: ; preds = %20, %22
%26 = phi i64 [ %23, %22 ], [ 2, %20 ]
%27 = urem i64 %15, %26
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %22
29: ; preds = %25, %22, %20, %13
%30 = phi i64 [ %14, %13 ], [ %15, %20 ], [ %14, %25 ], [ %15, %22 ]
%31 = add nuw i64 %15, 1
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %13
33: ; preds = %29
%34 = icmp eq i64 %30, 0
%35 = select i1 %34, i64 %11, i64 %30
br label %36
36: ; preds = %33, %9
%37 = phi i64 [ %11, %9 ], [ %35, %33 ]
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %37)
%39 = load i64, i64* %2
%40 = add i64 %39, -1
store i64 %40, i64* %2
%41 = icmp eq i64 %39, 0
br i1 %41, label %42, label %9
42: ; preds = %36, %0
ret i32 0
}