#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 */
double floor(double);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
double sqrt(int);
int main() {
  int t, r, k, i;
  double s, sq;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &r, &k);
    for (i = 0, s = sqrt(r); i < s; ++i) {
      sq = sqrt(r - i * i);
      if (floor(sq) == sq)
        k -= 4;
    }
    if (k >= 0)
      printf("possible\n");
    else
      printf("impossible\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     122c <main+0xec>
lea    0xe84(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1200 <main+0xc0>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
sub    %eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <floor@plt>
ucomisd -0x28(%rbp),%xmm0
jne    11ed <main+0xad>
jp     11ed <main+0xad>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x10(%rbp)
jmp    11f2 <main+0xb2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119f <main+0x5f>
cmpl   $0x0,-0x10(%rbp)
jl     121b <main+0xdb>
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0xe7>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
jmp    1161 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeb5(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x14(%rsp)
jae    1179 <main+0x39>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe88(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe7e(%rip),%r13
lea    0xe75(%rip),%rbx
jmp    11b8 <main+0x78>
nopw   0x0(%rax,%rax,1)
cmpl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
cmovns %r13,%rdi
call   1030 <puts@plt>
subl   $0x1,0x14(%rsp)
jb     1168 <main+0x28>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
ucomisd 0xe21(%rip),%xmm0
jbe    11a0 <main+0x60>
xor    %ebp,%ebp
jmp    1206 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11a0 <main+0x60>
mov    0x10(%rsp),%edi
mov    %ebp,%eax
imul   %ebp,%eax
sub    %eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x20(%rsp)
call   1060 <floor@plt>
ucomisd 0x20(%rsp),%xmm0
jne    11f0 <main+0xb0>
jp     11f0 <main+0xb0>
addl   $0xfffffffc,0xc(%rsp)
jmp    11f0 <main+0xb0>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [10 x i8] c"possible\0A\00"
@.str.3 = [12 x i8] c"impossible\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %47, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %48
13: ; preds = %9
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
store i32 0, i32* %5
%15 = load i32, i32* %3
%16 = call double @sqrt(i32 %15)
store double %16, double* %6
br label %17
17: ; preds = %37, %13
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
%20 = load double, double* %6
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %40
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = load i32, i32* %5
%26 = mul nsw i32 %24, %25
%27 = sub nsw i32 %23, %26
%28 = call double @sqrt(i32 %27)
store double %28, double* %7
%29 = load double, double* %7
%30 = call double @llvm.floor.f64(double %29)
%31 = load double, double* %7
%32 = fcmp oeq double %30, %31
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 4
store i32 %35, i32* %4
br label %36
36: ; preds = %33, %22
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %17
40: ; preds = %17
%41 = load i32, i32* %4
%42 = icmp sge i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
br label %9
48: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@str = [11 x i8] c"impossible\00"
@str.4 = [9 x i8] c"possible\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %39, label %11
11: ; preds = %0, %31
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %2
%14 = call double @sqrt(i32 %13)
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %31
16: ; preds = %11, %27
%17 = phi i32 [ %28, %27 ], [ 0, %11 ]
%18 = load i32, i32* %2
%19 = mul nsw i32 %17, %17
%20 = sub nsw i32 %18, %19
%21 = call double @sqrt(i32 %20)
%22 = call double @llvm.floor.f64(double %21)
%23 = fcmp oeq double %22, %21
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -4
store i32 %26, i32* %3
br label %27
27: ; preds = %16, %24
%28 = add nuw nsw i32 %17, 1
%29 = sitofp i32 %28 to double
%30 = fcmp ogt double %14, %29
br i1 %30, label %16, label %31
31: ; preds = %27, %11
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, -1
%34 = select i1 %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0)
%35 = call i32 @puts(i8* dereferenceable(1) %34)
%36 = load i32, i32* %1
%37 = add nsw i32 %36, -1
store i32 %37, i32* %1
%38 = icmp eq i32 %36, 0
br i1 %38, label %39, label %11
39: ; preds = %31, %0
ret i32 0
}