#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 *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int sqrt(int);
int circlecity(void) {
  int testCases = 0;
  int radiusSquared = 0;
  int policeStations = 0;
  int distinctFactors = 0;
  int factor = 0;
  scanf("%d", &testCases);
  while (testCases--) {
    scanf("%d %d", &radiusSquared, &policeStations);
    distinctFactors = 0;
    factor = 0;
    for (int factorSquared = 0; factorSquared < radiusSquared;
         factorSquared = factor * factor) {
      int otherFactorSquared = radiusSquared - factorSquared;
      int otherFactor = sqrt(otherFactorSquared);
      if (otherFactor * otherFactor == otherFactorSquared) {
        distinctFactors++;
      }
      factor++;
    }
    if (policeStations < distinctFactors * 4) {
      printf("impossible\n");
    } else {
      printf("possible\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<circlecity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1230 <circlecity+0x100>
lea    0xe78(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fd <circlecity+0xcd>
mov    -0x8(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11e5 <circlecity+0xb5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11ac <circlecity+0x7c>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    121f <circlecity+0xef>
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
jmp    122b <circlecity+0xfb>
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
jmp    116d <circlecity+0x3d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circlecity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xea6(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x10(%rsp)
jae    1181 <circlecity+0x51>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x14(%rsp),%r12
lea    0xe79(%rip),%r13
lea    0xe74(%rip),%rbx
jmp    11bc <circlecity+0x8c>
cs nopw 0x0(%rax,%rax,1)
shl    $0x2,%r14d
cmp    %r14d,0x14(%rsp)
mov    %rbx,%rdi
cmovl  %r13,%rdi
call   1030 <puts@plt>
subl   $0x1,0x10(%rsp)
jb     1170 <circlecity+0x40>
xor    %r14d,%r14d
lea    0xe3a(%rip),%rdi
lea    0xc(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jle    11a0 <circlecity+0x70>
xor    %r14d,%r14d
mov    $0x1,%r15d
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
sub    %eax,%ebp
mov    %ebp,%edi
call   1050 <sqrt@plt>
imul   %eax,%eax
xor    %ecx,%ecx
cmp    %ebp,%eax
sete   %cl
add    %ecx,%r14d
mov    %r15d,%eax
imul   %r15d,%eax
mov    0xc(%rsp),%ebp
add    $0x1,%r15d
cmp    %eax,%ebp
jg     11f0 <circlecity+0xc0>
jmp    11a0 <circlecity+0x70>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@str = [9 x i8] c"possible\00"
@str.4 = [11 x i8] c"impossible\00"
define i32 @circlecity() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%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 %40, label %11
11: ; preds = %0, %15
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %25, %11
%16 = phi i32 [ 0, %11 ], [ %35, %25 ]
%17 = load i32, i32* %3
%18 = shl nsw i32 %16, 2
%19 = icmp slt i32 %17, %18
%20 = select i1 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
%22 = load i32, i32* %1
%23 = add nsw i32 %22, -1
store i32 %23, i32* %1
%24 = icmp eq i32 %22, 0
br i1 %24, label %40, label %11
25: ; preds = %11, %25
%26 = phi i32 [ %38, %25 ], [ %13, %11 ]
%27 = phi i32 [ %35, %25 ], [ 0, %11 ]
%28 = phi i32 [ %36, %25 ], [ 0, %11 ]
%29 = phi i32 [ %37, %25 ], [ 0, %11 ]
%30 = sub nsw i32 %26, %29
%31 = call i32 @sqrt(i32 %30)
%32 = mul nsw i32 %31, %31
%33 = icmp eq i32 %32, %30
%34 = zext i1 %33 to i32
%35 = add nuw nsw i32 %27, %34
%36 = add nuw nsw i32 %28, 1
%37 = mul nsw i32 %36, %36
%38 = load i32, i32* %2
%39 = icmp sgt i32 %38, %37
br i1 %39, label %25, label %15
40: ; preds = %15, %0
ret i32 0
}