#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, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
main() {
  int n, i;
  scanf("%d", &n);
  int n1[n], n2[n];
  char str[n][10], str1[n][10];
  for (i = 0; i < n; i++) {
    scanf("%d %d %s %s", &n1[i], &n2[i], &str[i], str1[i]);
  }
  for (i = 0; i < n; i++) {
    if (str[i][0] == 'Q')
      printf("Q: %d R: %d\n", (n1[i] / n2[i]), (n1[i] % n2[i]));
    if (str[i][0] == 'R')
      printf("R: %d Q: %d\n", (n1[i] % n2[i]), (n1[i] / n2[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
lea    (%rax,%rax,4),%rcx
lea    0xf(%rcx,%rcx,1),%rsi
movabs $0x1ffffffff0,%rcx
and    %rcx,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
lea    (%rax,%rax,4),%rdx
lea    0xf(%rdx,%rdx,1),%rdx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123d <main+0x11d>
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
movslq -0xc(%rbp),%rax
imul   $0xa,%rax,%rax
add    %rax,%rcx
movslq -0xc(%rbp),%rax
imul   $0xa,%rax,%rax
add    %rax,%r8
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <main+0xb9>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    130b <main+0x1eb>
mov    -0x48(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x51,%eax
jne    12a3 <main+0x183>
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%rax
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,4),%eax
movslq -0xc(%rbp),%rsi
cltd
idivl  (%rcx,%rsi,4)
mov    %eax,%esi
mov    -0x58(%rbp),%rax
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,4),%eax
movslq -0xc(%rbp),%rdi
cltd
idivl  (%rcx,%rdi,4)
lea    0xd71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x52,%eax
jne    12f8 <main+0x1d8>
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%rax
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,4),%eax
movslq -0xc(%rbp),%rsi
cltd
idivl  (%rcx,%rsi,4)
mov    -0x58(%rbp),%rax
mov    %edx,%esi
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,4),%eax
movslq -0xc(%rbp),%rdi
cltd
idivl  (%rcx,%rdi,4)
mov    %eax,%edx
lea    0xd29(%rip),%rdi
call   1030 <printf@plt>
jmp    12fd <main+0x1dd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1244 <main+0x124>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xec8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%rdx
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
lea    (%rax,%rax,4),%rcx
add    %rcx,%rcx
add    $0xf,%rcx
movabs $0x1ffffffff0,%rdx
and    %rcx,%rdx
mov    %rsp,%rbx
sub    %rdx,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %rdx,%r15
mov    %r15,%rsp
test   %eax,%eax
jle    1273 <main+0x153>
mov    %r12,-0x48(%rbp)
mov    -0x38(%rbp),%r13
mov    %rbx,-0x40(%rbp)
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    0xe3c(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    $0xa,%rbx
add    $0x4,%r13
add    $0x4,%r12
add    $0xa,%r15
cmp    %rax,%r14
jl     11c0 <main+0xa0>
test   %eax,%eax
mov    -0x48(%rbp),%r13
mov    -0x40(%rbp),%r14
jle    1273 <main+0x153>
xor    %ebx,%ebx
lea    0xe03(%rip),%r15
lea    0xe09(%rip),%r12
jmp    1231 <main+0x111>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0xa,%r14
cmp    %rax,%rbx
jge    1273 <main+0x153>
movzbl (%r14),%eax
cmp    $0x51,%al
jne    1254 <main+0x134>
mov    0x0(%r13,%rbx,4),%eax
cltd
mov    -0x38(%rbp),%rcx
idivl  (%rcx,%rbx,4)
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movzbl (%r14),%eax
cmp    $0x52,%al
jne    1220 <main+0x100>
mov    0x0(%r13,%rbx,4),%eax
cltd
mov    -0x38(%rbp),%rcx
idivl  (%rcx,%rbx,4)
mov    %r12,%rdi
mov    %edx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
jmp    1220 <main+0x100>
mov    -0x50(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%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 = [12 x i8] c"%d %d %s %s\00"
@.str.2 = [13 x i8] c"Q: %d R: %d\0A\00"
@.str.3 = [13 x i8] c"R: %d Q: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %4
%13 = alloca i32, i64 %11
store i64 %11, i64* %5
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
%16 = alloca i32, i64 %15
store i64 %15, i64* %6
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = alloca [10 x i8], i64 %18
store i64 %18, i64* %7
%20 = load i32, i32* %2
%21 = zext i32 %20 to i64
%22 = alloca [10 x i8], i64 %21
store i64 %21, i64* %8
store i32 0, i32* %3
br label %23
23: ; preds = %42, %0
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %13, i64 %29
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %16, i64 %32
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 %35
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 %38
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %39, i64 0, i64 0
%41 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %30, i32* %33, [10 x i8]* %36, i8* %40)
br label %42
42: ; preds = %27
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %23
45: ; preds = %23
store i32 0, i32* %3
br label %46
46: ; preds = %107, %45
%47 = load i32, i32* %3
%48 = load i32, i32* %2
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %110
50: ; preds = %46
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 %52
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %53, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 81
br i1 %57, label %58, label %78
58: ; preds = %50
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %13, i64 %60
%62 = load i32, i32* %61
%63 = load i32, i32* %3
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %16, i64 %64
%66 = load i32, i32* %65
%67 = sdiv i32 %62, %66
%68 = load i32, i32* %3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %13, i64 %69
%71 = load i32, i32* %70
%72 = load i32, i32* %3
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %16, i64 %73
%75 = load i32, i32* %74
%76 = srem i32 %71, %75
%77 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %67, i32 %76)
br label %78
78: ; preds = %58, %50
%79 = load i32, i32* %3
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 %80
%82 = getelementptr inbounds [10 x i8], [10 x i8]* %81, i64 0, i64 0
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 82
br i1 %85, label %86, label %106
86: ; preds = %78
%87 = load i32, i32* %3
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %13, i64 %88
%90 = load i32, i32* %89
%91 = load i32, i32* %3
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %16, i64 %92
%94 = load i32, i32* %93
%95 = srem i32 %90, %94
%96 = load i32, i32* %3
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %13, i64 %97
%99 = load i32, i32* %98
%100 = load i32, i32* %3
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %16, i64 %101
%103 = load i32, i32* %102
%104 = sdiv i32 %99, %103
%105 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %95, i32 %104)
br label %106
106: ; preds = %86, %78
br label %107
107: ; preds = %106
%108 = load i32, i32* %3
%109 = add nsw i32 %108, 1
store i32 %109, i32* %3
br label %46
110: ; preds = %46
store i32 0, i32* %1
%111 = load i8*, i8** %4
%112 = load i32, i32* %1
ret i32 %112
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"%d %d %s %s\00"
@.str.2 = [13 x i8] c"Q: %d R: %d\0A\00"
@.str.3 = [13 x i8] c"R: %d Q: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i32, i64 %5
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = alloca i32, i64 %9
%11 = alloca [10 x i8], i64 %9
%12 = alloca [10 x i8], i64 %9
%13 = icmp sgt i32 %8, 0
br i1 %13, label %16, label %57
14: ; preds = %16
%15 = icmp sgt i32 %24, 0
br i1 %15, label %27, label %57
16: ; preds = %0, %16
%17 = phi i64 [ %23, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds i32, i32* %7, i64 %17
%19 = getelementptr inbounds i32, i32* %10, i64 %17
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 %17
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 %17, i64 0
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %18, i32* %19, [10 x i8]* %20, i8* %21)
%23 = add nuw nsw i64 %17, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %16, label %14
27: ; preds = %14, %52
%28 = phi i64 [ %53, %52 ], [ 0, %14 ]
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 %28, i64 0
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 81
br i1 %31, label %32, label %41
32: ; preds = %27
%33 = getelementptr inbounds i32, i32* %7, i64 %28
%34 = load i32, i32* %33
%35 = getelementptr inbounds i32, i32* %10, i64 %28
%36 = load i32, i32* %35
%37 = sdiv i32 %34, %36
%38 = srem i32 %34, %36
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %38)
%40 = load i8, i8* %29
br label %41
41: ; preds = %32, %27
%42 = phi i8 [ %40, %32 ], [ %30, %27 ]
%43 = icmp eq i8 %42, 82
br i1 %43, label %44, label %52
44: ; preds = %41
%45 = getelementptr inbounds i32, i32* %7, i64 %28
%46 = load i32, i32* %45
%47 = getelementptr inbounds i32, i32* %10, i64 %28
%48 = load i32, i32* %47
%49 = srem i32 %46, %48
%50 = sdiv i32 %46, %48
%51 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50)
br label %52
52: ; preds = %41, %44
%53 = add nuw nsw i64 %28, 1
%54 = load i32, i32* %1
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %53, %55
br i1 %56, label %27, label %57
57: ; preds = %52, %0, %14
ret i32 0
}