#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 /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int casos, a, b;
  char op;
  scanf("%d\n", &casos);
  while (casos-- > 0) {
    scanf("%d%c%d\n", &a, &op, &b);
    if (a == b) {
      printf("%d\n", a * b);
    } else if (((op) >= 'A' && (op) <= 'Z')) {
      printf("%d\n", b - a);
    } else {
      printf("%d\n", a + b);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%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
jle    11e0 <main+0xc0>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x11(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1193 <main+0x73>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11db <main+0xbb>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jl     11c4 <main+0xa4>
movsbl -0x11(%rbp),%eax
cmp    $0x5a,%eax
jg     11c4 <main+0xa4>
mov    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d6 <main+0xb6>
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
jmp    11db <main+0xbb>
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    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    11c0 <main+0xa0>
lea    0xeaa(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x3(%rsp),%r12
lea    0x8(%rsp),%r13
lea    0xe98(%rip),%rbx
jmp    118c <main+0x6c>
xchg   %ax,%ax
imul   %eax,%eax
mov    %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    11c0 <main+0xa0>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ecx
mov    %ecx,%esi
sub    %eax,%esi
je     1170 <main+0x50>
movzbl 0x3(%rsp),%edx
add    $0xbf,%dl
cmp    $0x19,%dl
jbe    1175 <main+0x55>
add    %eax,%ecx
mov    %ecx,%esi
jmp    1175 <main+0x55>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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