#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() {
  int t, i, j, k, n, p;
  scanf("%d", &t);
  while (t--) {
    char s[5];
    scanf("%d%s%d", &n, s, &p);
    if (s[0] == 'e') {
      printf("%d\n", 2 * p - 1);
    } else
      printf("%d\n", 2 * p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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
je     11ad <main+0x8d>
lea    -0x21(%rbp),%rdx
lea    0xea0(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x21(%rbp),%eax
cmp    $0x65,%eax
jne    1196 <main+0x76>
mov    -0x1c(%rbp),%esi
shl    $0x1,%esi
sub    $0x1,%esi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <main+0x88>
mov    -0x1c(%rbp),%esi
shl    $0x1,%esi
lea    0xe64(%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   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     11a4 <main+0x84>
lea    0xeb2(%rip),%r14
lea    0x1c(%rsp),%r15
lea    0x17(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xea3(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
xor    %eax,%eax
cmpb   $0x65,0x17(%rsp)
sete   %al
mov    0x10(%rsp),%esi
add    %esi,%esi
sub    %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    1170 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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