#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
main() {
  char s[100000];
  int i, j, k, l, m, n;
  scanf("%d", &n);
  getchar();
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    l = strlen(s);
    if (l == 1 && (s[0] == '4' || s[0] == '1')) {
      printf("+\n");
      continue;
    }
    if (l == 2 && s[0] == '7' && s[1] == '8') {
      printf("+\n");
      continue;
    }
    if (l >= 3) {
      if (s[l - 2] == '3' && s[l - 1] == '5')
        printf("-\n");
      else if (s[0] == '9' && s[l - 1] == '4')
        printf("*\n");
      else if (s[0] == '1' && s[1] == '9' && s[2] == '0')
        printf("?\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x186c8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x186b4(%rbp)
mov    -0x186b4(%rbp),%eax
cmp    -0x186c8(%rbp),%eax
jge    1324 <main+0x1e4>
lea    -0x186b0(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x186b0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x186c0(%rbp)
cmpl   $0x1,-0x186c0(%rbp)
jne    11ef <main+0xaf>
movsbl -0x186b0(%rbp),%eax
cmp    $0x34,%eax
je     11de <main+0x9e>
movsbl -0x186b0(%rbp),%eax
cmp    $0x31,%eax
jne    11ef <main+0xaf>
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
jmp    1310 <main+0x1d0>
cmpl   $0x2,-0x186c0(%rbp)
jne    122d <main+0xed>
movsbl -0x186b0(%rbp),%eax
cmp    $0x37,%eax
jne    122d <main+0xed>
movsbl -0x186af(%rbp),%eax
cmp    $0x38,%eax
jne    122d <main+0xed>
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
jmp    1310 <main+0x1d0>
cmpl   $0x3,-0x186c0(%rbp)
jl     130b <main+0x1cb>
mov    -0x186c0(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x186b0(%rbp,%rax,1),%eax
ff
cmp    $0x33,%eax
jne    1283 <main+0x143>
mov    -0x186c0(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x186b0(%rbp,%rax,1),%eax
ff
cmp    $0x35,%eax
jne    1283 <main+0x143>
lea    0xd90(%rip),%rdi
call   1040 <printf@plt>
jmp    1306 <main+0x1c6>
movsbl -0x186b0(%rbp),%eax
cmp    $0x39,%eax
jne    12c0 <main+0x180>
mov    -0x186c0(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x186b0(%rbp,%rax,1),%eax
ff
cmp    $0x34,%eax
jne    12c0 <main+0x180>
lea    0xd56(%rip),%rdi
call   1040 <printf@plt>
jmp    1301 <main+0x1c1>
movsbl -0x186b0(%rbp),%eax
cmp    $0x31,%eax
jne    12fc <main+0x1bc>
movsbl -0x186af(%rbp),%eax
cmp    $0x39,%eax
jne    12fc <main+0x1bc>
movsbl -0x186ae(%rbp),%eax
cmp    $0x30,%eax
jne    12fc <main+0x1bc>
lea    0xd18(%rip),%rdi
call   1040 <printf@plt>
jmp    1301 <main+0x1c1>
jmp    1306 <main+0x1c6>
jmp    130b <main+0x1cb>
jmp    1310 <main+0x1d0>
mov    -0x186b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186b4(%rbp)
jmp    1178 <main+0x38>
xor    %eax,%eax
add    $0x186d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186b8,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    126b <main+0x12b>
lea    0xe86(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe83(%rip),%r15
lea    0xe7a(%rip),%r12
lea    0xe71(%rip),%r13
xor    %ebp,%ebp
jmp    11b2 <main+0x72>
nopl   0x0(%rax,%rax,1)
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    126b <main+0x12b>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movzbl 0x10(%rsp),%ecx
cmp    $0x1,%eax
jne    11f0 <main+0xb0>
mov    %r15,%rdi
cmp    $0x31,%cl
je     11a0 <main+0x60>
mov    %r15,%rdi
cmp    $0x34,%cl
je     11a0 <main+0x60>
jmp    11a5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x11(%rsp),%edx
cmp    $0x2,%eax
jne    1207 <main+0xc7>
cmp    $0x37,%cl
jne    1207 <main+0xc7>
mov    %r15,%rdi
cmp    $0x38,%dl
je     11a0 <main+0x60>
cmp    $0x3,%eax
jl     11a5 <main+0x65>
lea    -0x2(%rax),%esi
cmpb   $0x33,0x10(%rsp,%rsi,1)
jne    1227 <main+0xe7>
lea    -0x1(%rax),%esi
cmpb   $0x35,0x10(%rsp,%rsi,1)
mov    %r12,%rdi
je     11a0 <main+0x60>
cmp    $0x39,%cl
jne    1242 <main+0x102>
add    $0xffffffff,%eax
cmpb   $0x34,0x10(%rsp,%rax,1)
mov    %r13,%rdi
je     11a0 <main+0x60>
jmp    11a5 <main+0x65>
cmp    $0x31,%cl
jne    11a5 <main+0x65>
cmp    $0x39,%dl
jne    11a5 <main+0x65>
cmpb   $0x30,0x12(%rsp)
lea    0xda6(%rip),%rdi
je     11a0 <main+0x60>
jmp    11a5 <main+0x65>
xor    %eax,%eax
add    $0x186b8,%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 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"+\0A\00"
@.str.3 = [3 x i8] c"-\0A\00"
@.str.4 = [3 x i8] c"*\0A\00"
@.str.5 = [3 x i8] c"?\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = call i32 (...) @getchar()
store i32 0, i32* %3
br label %11
11: ; preds = %106, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %109
15: ; preds = %11
%16 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %34
22: ; preds = %15
%23 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 52
br i1 %26, label %32, label %27
27: ; preds = %22
%28 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 49
br i1 %31, label %32, label %34
32: ; preds = %27, %22
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %106
34: ; preds = %27, %15
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %49
37: ; preds = %34
%38 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 55
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 56
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %106
49: ; preds = %42, %37, %34
%50 = load i32, i32* %6
%51 = icmp sge i32 %50, 3
br i1 %51, label %52, label %105
52: ; preds = %49
%53 = load i32, i32* %6
%54 = sub nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 51
br i1 %59, label %60, label %70
60: ; preds = %52
%61 = load i32, i32* %6
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 53
br i1 %67, label %68, label %70
68: ; preds = %60
%69 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %104
70: ; preds = %60, %52
%71 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 57
br i1 %74, label %75, label %85
75: ; preds = %70
%76 = load i32, i32* %6
%77 = sub nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 %78
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 52
br i1 %82, label %83, label %85
83: ; preds = %75
%84 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %103
85: ; preds = %75, %70
%86 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 49
br i1 %89, label %90, label %102
90: ; preds = %85
%91 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 1
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 57
br i1 %94, label %95, label %102
95: ; preds = %90
%96 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 2
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 48
br i1 %99, label %100, label %102
100: ; preds = %95
%101 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %102
102: ; preds = %100, %95, %90, %85
br label %103
103: ; preds = %102, %83
br label %104
104: ; preds = %103, %68
br label %105
105: ; preds = %104, %49
br label %106
106: ; preds = %105, %47, %32
%107 = load i32, i32* %3
%108 = add nsw i32 %107, 1
store i32 %108, i32* %3
br label %11
109: ; preds = %11
ret i32 0
}

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