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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11bc <main+0x9c>
lea    0xe9f(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11a5 <main+0x85>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,%rsi
mov    -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x97>
mov    -0x18(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,0x8(%rsp)
jb     11d8 <main+0xb8>
lea    0xead(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xeb1(%rip),%r12
lea    0xe9f(%rip),%r13
jmp    1185 <main+0x65>
nopl   (%rax)
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
subq   $0x1,0x8(%rsp)
jb     11d8 <main+0xb8>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rax
test   %rcx,%rcx
je     1170 <main+0x50>
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     11c0 <main+0xa0>
cqto
idiv   %rcx
mov    %rax,%rsi
jmp    11c6 <main+0xa6>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
subq   $0x1,0x8(%rsp)
jae    1185 <main+0x65>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [11 x i8] c"%lld %lld\0A\00"
@.str.3 = [8 x i8] c"0 %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %6
6: ; preds = %25, %0
%7 = load i64, i64* %2
%8 = add nsw i64 %7, -1
store i64 %8, i64* %2
%9 = icmp ne i64 %7, 0
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i32 (i8*, i64*, ...) @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 %14, label %22
14: ; preds = %10
%15 = load i64, i64* %3
%16 = load i64, i64* %4
%17 = sdiv i64 %15, %16
%18 = load i64, i64* %3
%19 = load i64, i64* %4
%20 = srem i64 %18, %19
%21 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %17, i64 %20)
br label %25
22: ; preds = %10
%23 = load i64, i64* %3
%24 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %22, %14
br label %6
26: ; preds = %6
ret i32 0
}

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