#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 *, long long, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  unsigned int T;
  long long int N, K;
  scanf("%d", &T);
  while (T--) {
    scanf("%lld %lld", &N, &K);
    if (!K && N) {
      printf("%lld %lld\n", 0LL, N);
    } else if (!N && !K) {
      printf("%lld %lld\n", 0LL, 0LL);
    } else {
      printf("%lld %lld\n", N / K, N % K);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%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     11f5 <main+0xd5>
lea    0xea7(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x0,-0x18(%rbp)
jne    119a <main+0x7a>
cmpq   $0x0,-0x10(%rbp)
je     119a <main+0x7a>
mov    -0x10(%rbp),%rdx
lea    0xe81(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
cmpq   $0x0,-0x10(%rbp)
jne    11c8 <main+0xa8>
cmpq   $0x0,-0x18(%rbp)
jne    11c8 <main+0xa8>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1030 <printf@plt>
jmp    11eb <main+0xcb>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xea9(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xea2(%rip),%rbx
jmp    1183 <main+0x63>
nopl   (%rax)
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1145 <main+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rdx
test   %rcx,%rcx
jne    11b0 <main+0x90>
test   %rdx,%rdx
je     11b0 <main+0x90>
mov    %rbx,%rdi
xor    %esi,%esi
jmp    1177 <main+0x57>
xchg   %ax,%ax
mov    %rdx,%rax
or     %rcx,%rax
je     1170 <main+0x50>
shr    $0x20,%rax
je     11c8 <main+0xa8>
mov    %rdx,%rax
cqto
idiv   %rcx
jmp    11ce <main+0xae>
mov    %edx,%eax
xor    %edx,%edx
div    %ecx
mov    %rbx,%rdi
mov    %rax,%rsi
jmp    1177 <main+0x57>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [11 x i8] c"%lld %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %37, %0
%7 = load i32, i32* %2
%8 = add i32 %7, -1
store i32 %8, i32* %2
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %38
10: ; preds = %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %4)
%12 = load i64, i64* %4
%13 = icmp ne i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %10
%15 = load i64, i64* %3
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i64, i64* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 0, i64 %18)
br label %37
20: ; preds = %14, %10
%21 = load i64, i64* %3
%22 = icmp ne i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = load i64, i64* %4
%25 = icmp ne i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 0, i64 0)
br label %36
28: ; preds = %23, %20
%29 = load i64, i64* %3
%30 = load i64, i64* %4
%31 = sdiv i64 %29, %30
%32 = load i64, i64* %3
%33 = load i64, i64* %4
%34 = srem i64 %32, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %31, i64 %34)
br label %36
36: ; preds = %28, %26
br label %37
37: ; preds = %36, %17
br label %6
38: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [11 x i8] c"%lld %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i32* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %33, label %11
11: ; preds = %0, %29
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, 0
%15 = load i64, i64* %2
%16 = icmp ne i64 %15, 0
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 0, i64 %15)
br label %29
20: ; preds = %11
%21 = icmp ne i64 %13, 0
%22 = select i1 %16, i1 true, i1 %21
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 0, i64 0)
br label %29
25: ; preds = %20
%26 = sdiv i64 %15, %13
%27 = srem i64 %15, %13
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %26, i64 %27)
br label %29
29: ; preds = %23, %25, %18
%30 = load i32, i32* %1
%31 = add i32 %30, -1
store i32 %31, i32* %1
%32 = icmp eq i32 %30, 0
br i1 %32, label %33, label %11
33: ; preds = %29, %0
ret i32 0
}