#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*/ findPrimefactors(long);
long gcd(long, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *);
scalar_t__ sqrt(long);
int totalDivisors();
long totalEvenPerfectSquare();
int main() {
  long int t;
  long int x;
  long int a, b, c, g;
  scanf("%ld", &t);
  while (t--) {
    scanf("%ld", &x);
    findPrimefactors(x);
    b = totalDivisors() - 1;
    a = totalEvenPerfectSquare();
    c = (int long)sqrt(x);
    if (x == c * c && x % 4 == 0) {
      a--;
    }
    if (a == 0)
      printf("0\n");
    else {
      g = gcd(a, b);
      a /= g;
      b /= g;
      printf("%ld/%ld\n", a, b);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     128f <main+0x11f>
lea    0xe51(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <findPrimefactors@plt>
mov    $0x0,%al
call   1070 <totalDivisors@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <totalEvenPerfectSquare@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <sqrt@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
imul   -0x30(%rbp),%rcx
cmp    %rcx,%rax
jne    1223 <main+0xb3>
mov    -0x18(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1223 <main+0xb3>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1241 <main+0xd1>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128a <main+0x11a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <gcd@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <main+0x1f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe6b(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1070 <scanf@plt>
subq   $0x1,0x10(%rsp)
jb     12ae <main+0x12e>
lea    0xe4e(%rip),%r14
lea    0x8(%rsp),%r13
lea    0xe46(%rip),%r12
jmp    11d8 <main+0x58>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
subq   $0x1,0x10(%rsp)
jb     12ae <main+0x12e>
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%rdi
call   1050 <findPrimefactors@plt>
xor    %eax,%eax
call   1080 <totalDivisors@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <totalEvenPerfectSquare@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
call   10a0 <sqrt@plt>
mov    0x8(%rsp),%rcx
imul   %rax,%rax
xor    %rcx,%rax
and    $0x3,%ecx
xor    %edx,%edx
or     %rax,%rcx
sete   %dl
sub    %rdx,%rbx
je     11c0 <main+0x40>
add    $0xffffffff,%ebp
movslq %ebp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <gcd@plt>
mov    %rax,%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1260 <main+0xe0>
mov    %rbx,%rax
cqto
idiv   %rcx
mov    %rax,%rsi
jmp    1268 <main+0xe8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
mov    %rcx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     1290 <main+0x110>
mov    %r15,%rax
cqto
idiv   %rcx
mov    %rax,%rdx
jmp    1298 <main+0x118>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%edx
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
subq   $0x1,0x10(%rsp)
jae    11d8 <main+0x58>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [9 x i8] c"%ld/%ld\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 i64
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %9
9: ; preds = %53, %0
%10 = load i64, i64* %2
%11 = add nsw i64 %10, -1
store i64 %11, i64* %2
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %54
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%15 = load i64, i64* %3
%16 = call i32 @findPrimefactors(i64 %15)
%17 = call i32 (...) @totalDivisors()
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
store i64 %19, i64* %5
%20 = call i64 (...) @totalEvenPerfectSquare()
store i64 %20, i64* %4
%21 = load i64, i64* %3
%22 = call i64 @sqrt(i64 %21)
store i64 %22, i64* %6
%23 = load i64, i64* %3
%24 = load i64, i64* %6
%25 = load i64, i64* %6
%26 = mul nsw i64 %24, %25
%27 = icmp eq i64 %23, %26
br i1 %27, label %28, label %35
28: ; preds = %13
%29 = load i64, i64* %3
%30 = srem i64 %29, 4
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i64, i64* %4
%34 = add nsw i64 %33, -1
store i64 %34, i64* %4
br label %35
35: ; preds = %32, %28, %13
%36 = load i64, i64* %4
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %53
40: ; preds = %35
%41 = load i64, i64* %4
%42 = load i64, i64* %5
%43 = call i64 @gcd(i64 %41, i64 %42)
store i64 %43, i64* %7
%44 = load i64, i64* %7
%45 = load i64, i64* %4
%46 = sdiv i64 %45, %44
store i64 %46, i64* %4
%47 = load i64, i64* %7
%48 = load i64, i64* %5
%49 = sdiv i64 %48, %47
store i64 %49, i64* %5
%50 = load i64, i64* %4
%51 = load i64, i64* %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %50, i64 %51)
br label %53
53: ; preds = %40, %38
br label %9
54: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.2 = [9 x i8] c"%ld/%ld\0A\00"
@str = [2 x i8] c"0\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* %1)
%6 = load i64, i64* %1
%7 = add nsw i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %39, label %9
9: ; preds = %0, %35
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = call i32 @findPrimefactors(i64 %11)
%13 = call i32 (...) @totalDivisors()
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = call i64 (...) @totalEvenPerfectSquare()
%17 = load i64, i64* %2
%18 = call i64 @sqrt(i64 %17)
%19 = load i64, i64* %2
%20 = mul nsw i64 %18, %18
%21 = icmp eq i64 %19, %20
%22 = and i64 %19, 3
%23 = icmp eq i64 %22, 0
%24 = and i1 %21, %23
%25 = sext i1 %24 to i64
%26 = add nsw i64 %16, %25
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %9
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %35
30: ; preds = %9
%31 = call i64 @gcd(i64 %26, i64 %15)
%32 = sdiv i64 %26, %31
%33 = sdiv i64 %15, %31
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %32, i64 %33)
br label %35
35: ; preds = %30, %28
%36 = load i64, i64* %1
%37 = add nsw i64 %36, -1
store i64 %37, i64* %1
%38 = icmp eq i64 %36, 0
br i1 %38, label %39, label %9
39: ; preds = %35, %0
ret i32 0
}