#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 */
scalar_t__ ceil(double);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int T;
  int x, k;
  scanf("%d", &T);
  while (T-- > 0) {
    scanf("%d%d", &x, &k);
    if (x / k == (int)ceil(1.0 * x / k)) {
      printf("0 %d\n", k);
    } else {
      printf("%d %d\n", -x, x);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11e3 <main+0xb3>
lea    0xe9c(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe6e(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %rax,%rcx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jne    11c8 <main+0x98>
mov    -0x10(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11de <main+0xae>
xor    %esi,%esi
sub    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x20,%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    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
test   %eax,%eax
jle    11fb <main+0xcb>
lea    0xe95(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xe89(%rip),%r12
lea    0xe88(%rip),%r13
jmp    11b1 <main+0x81>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x14(%rsp),%edx
mov    %edx,%esi
neg    %esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
test   %eax,%eax
jle    11fb <main+0xcb>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%esi
mov    %ecx,%eax
cltd
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
idiv   %esi
mov    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
cmp    %eax,%ebp
jne    1190 <main+0x60>
mov    0x10(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a2 <main+0x72>
xor    %eax,%eax
add    $0x18,%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 = [5 x i8] c"%d%d\00"
@.str.2 = [6 x i8] c"0 %d\0A\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %32, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %33
10: ; preds = %6
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = sdiv i32 %12, %13
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = fmul double 1.000000e+00, %16
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
%21 = call i64 @ceil(double %20)
%22 = trunc i64 %21 to i32
%23 = icmp eq i32 %14, %22
br i1 %23, label %24, label %27
24: ; preds = %10
%25 = load i32, i32* %4
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %32
27: ; preds = %10
%28 = load i32, i32* %3
%29 = sub nsw i32 0, %28
%30 = load i32, i32* %3
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %27, %24
br label %6
33: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [6 x i8] c"0 %d\0A\00"
@.str.3 = [7 x i8] c"%d %d\0A\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 sgt i32 %8, 0
br i1 %10, label %11, label %33
11: ; preds = %0, %29
%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 = load i32, i32* %3
%15 = sdiv i32 %13, %14
%16 = sitofp i32 %13 to double
%17 = sitofp i32 %14 to double
%18 = fdiv double %16, %17
%19 = call i64 @ceil(double %18)
%20 = trunc i64 %19 to i32
%21 = icmp eq i32 %15, %20
br i1 %21, label %22, label %25
22: ; preds = %11
%23 = load i32, i32* %3
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %29
25: ; preds = %11
%26 = load i32, i32* %2
%27 = sub nsw i32 0, %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %26)
br label %29
29: ; preds = %25, %22
%30 = load i32, i32* %1
%31 = add nsw i32 %30, -1
store i32 %31, i32* %1
%32 = icmp sgt i32 %30, 0
br i1 %32, label %11, label %33
33: ; preds = %29, %0
ret i32 0
}