#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() {
  int t;
  long long n, k;
  register long long each_child, teacher;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &n, &k);
    if (n == 0) {
      each_child = teacher = 0;
    } else if (k == 0) {
      each_child = 0;
      teacher = n;
    } else {
      each_child = n / k;
      teacher = n % k;
    }
    printf("%lld %lld\n", each_child, teacher);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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     11e5 <main+0xc5>
lea    0xea7(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    118b <main+0x6b>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
jmp    11cc <main+0xac>
cmpq   $0x0,-0x18(%rbp)
jne    11ab <main+0x8b>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11c7 <main+0xa7>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rdx,-0x28(%rbp)
jmp    11cc <main+0xac>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x30,%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)
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rdi
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    0x10(%rsp),%rdx
test   %rdx,%rdx
je     1170 <main+0x50>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     11c0 <main+0xa0>
mov    %rdx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11c4 <main+0xa4>
mov    %rdx,%rax
cqto
idiv   %rcx
mov    %rax,%rsi
jmp    1174 <main+0x54>
xor    %esi,%esi
jmp    1174 <main+0x54>
mov    %edx,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
jmp    1174 <main+0x54>

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
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %30, %0
%9 = load i32, i32* %2
%10 = add nsw i32 %9, -1
store i32 %10, i32* %2
%11 = icmp ne i32 %9, 0
br i1 %11, label %12, label %34
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %4)
%14 = load i64, i64* %3
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i64 0, i64* %6
store i64 0, i64* %5
br label %30
17: ; preds = %12
%18 = load i64, i64* %4
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
store i64 0, i64* %5
%21 = load i64, i64* %3
store i64 %21, i64* %6
br label %29
22: ; preds = %17
%23 = load i64, i64* %3
%24 = load i64, i64* %4
%25 = sdiv i64 %23, %24
store i64 %25, i64* %5
%26 = load i64, i64* %3
%27 = load i64, i64* %4
%28 = srem i64 %26, %27
store i64 %28, i64* %6
br label %29
29: ; preds = %22, %20
br label %30
30: ; preds = %29, %16
%31 = load i64, i64* %5
%32 = load i64, i64* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %31, i64 %32)
br label %8
34: ; preds = %8
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 nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %28, label %11
11: ; preds = %0, %21
%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* %2
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = load i64, i64* %3
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = sdiv i64 %13, %16
%20 = srem i64 %13, %16
br label %21
21: ; preds = %15, %11, %18
%22 = phi i64 [ %19, %18 ], [ 0, %11 ], [ 0, %15 ]
%23 = phi i64 [ %20, %18 ], [ 0, %11 ], [ %13, %15 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %22, i64 %23)
%25 = load i32, i32* %1
%26 = add nsw i32 %25, -1
store i32 %26, i32* %1
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %11
28: ; preds = %21, %0
ret i32 0
}