#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int case_num;
  scanf("%d%*c", &case_num);
  while (case_num--) {
    int ans = 0;
    int continuous = 0;
    int ch;
    ch = getchar();
    while (ch != '\n' && ch != EOF) {
      if (ch == 'X') {
        continuous = 0;
      } else if (ch == 'O') {
        ++continuous;
        ans += continuous;
      }
      ch = getchar();
    }
    printf("%d\n", ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1206 <main+0xd6>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x14(%rbp)
mov    %al,-0x15(%rbp)
je     119c <main+0x6c>
mov    -0x14(%rbp),%eax
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11ac <main+0x7c>
jmp    11f2 <main+0xc2>
cmpl   $0x58,-0x14(%rbp)
jne    11c2 <main+0x92>
movl   $0x0,-0x10(%rbp)
jmp    11e3 <main+0xb3>
cmpl   $0x4f,-0x14(%rbp)
jne    11de <main+0xae>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e3 <main+0xb3>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x4b>
mov    -0xc(%rbp),%esi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    115e <main+0x2e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e83(%rip),%r15
lea    0xe9a(%rip),%r14
jmp    1182 <main+0x52>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1150 <main+0x20>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%r12d
cmp    $0xa,%eax
je     1170 <main+0x40>
mov    $0x0,%r12d
cmp    (%r15),%eax
je     1170 <main+0x40>
xor    %ebx,%ebx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x58,%eax
je     11d0 <main+0xa0>
cmp    $0x4f,%eax
jne    11d2 <main+0xa2>
add    %ebx,%r12d
add    $0x1,%r12d
mov    %ebx,%eax
add    $0x1,%eax
mov    %eax,%ebx
jmp    11d2 <main+0xa2>
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1170 <main+0x40>
cmp    (%r15),%eax
jne    11b0 <main+0x80>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"%d%*c\00"
@EOF = global i32 0
@.str.1 = [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
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %38, %0
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
store i32 %9, i32* %2
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %41
11: ; preds = %7
store i32 0, i32* %3
store i32 0, i32* %4
%12 = call i32 (...) @getchar()
store i32 %12, i32* %5
br label %13
13: ; preds = %36, %11
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %5
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br label %20
20: ; preds = %16, %13
%21 = phi i1 [ false, %13 ], [ %19, %16 ]
br i1 %21, label %22, label %38
22: ; preds = %20
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 88
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 0, i32* %4
br label %36
26: ; preds = %22
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 79
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = add nsw i32 %33, %32
store i32 %34, i32* %3
br label %35
35: ; preds = %29, %26
br label %36
36: ; preds = %35, %25
%37 = call i32 (...) @getchar()
store i32 %37, i32* %5
br label %13
38: ; preds = %20
%39 = load i32, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %7
41: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d%*c\00"
@EOF = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = add nsw i32 %4, -1
store i32 %5, i32* %1
%6 = icmp eq i32 %4, 0
br i1 %6, label %35, label %7
7: ; preds = %0, %29
%8 = call i32 (...) @getchar()
%9 = icmp ne i32 %8, 10
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %8, %10
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %29
13: ; preds = %7, %21
%14 = phi i32 [ %24, %21 ], [ %8, %7 ]
%15 = phi i32 [ %23, %21 ], [ 0, %7 ]
%16 = phi i32 [ %22, %21 ], [ 0, %7 ]
switch i32 %14, label %20 [
i32 88, label %21
i32 79, label %17
]
17: ; preds = %13
%18 = add nsw i32 %15, 1
%19 = add nsw i32 %18, %16
br label %21
20: ; preds = %13
br label %21
21: ; preds = %13, %20, %17
%22 = phi i32 [ %19, %17 ], [ %16, %13 ], [ %16, %20 ]
%23 = phi i32 [ %18, %17 ], [ 0, %13 ], [ %15, %20 ]
%24 = call i32 (...) @getchar()
%25 = icmp ne i32 %24, 10
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %24, %26
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %13, label %29
29: ; preds = %21, %7
%30 = phi i32 [ 0, %7 ], [ %22, %21 ]
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
%33 = add nsw i32 %32, -1
store i32 %33, i32* %1
%34 = icmp eq i32 %32, 0
br i1 %34, label %35, label %7
35: ; preds = %29, %0
ret i32 0
}