n = int(input())
ox = []

for i in range(n):
    ox.append(input())

for x in ox:
    count = 0
    answer = 0
    for k in range(len(x)):
        if x[k] == "O":
            count += 1
            answer += count
        else:
            count = 0
            
    print(answer)

 

def distance(hand, number):
    keypad = [[1, 2, 3], [4, 5, 6], [7, 8, 9], ['*', 0, '#']]
    hand_ = ""
    num_ = ""
    
    for i in range(len(keypad)):
        for j in range(len(keypad[0])):
            if keypad[i][j] == hand:
                hand_coord = (i, j)
            if keypad[i][j] == number:
                num_coord = (i, j)
    return abs(hand_coord[0]-num_coord[0]) + abs(hand_coord[1]-num_coord[1])

def solution(numbers, hand):
    answer = ""
    left = "*"
    right = "#"

    for number in numbers:
        if number in [1, 4, 7]:
            answer += "L"
            left = number
        elif number in [3, 6, 9]:
            answer += "R"
            right = number
        else:
            left_d = distance(left, number)
            right_d = distance(right, number)
            if (left_d < right_d) or ((left_d == right_d) and (hand == "left")):
                answer += "L"
                left = number
            elif (left_d > right_d) or ((left_d == right_d) and (hand == "right")):
                answer += "R"
                right = number
    return answer

 

def solution(arr1, arr2):
    answer = []
    
    for idx1 in range(len(arr1)):
        row = []
        for idx2 in range(len(arr2[0])):
            num = 0
            for idx3 in range(len(arr1[0])):
                num += arr1[idx1][idx3] * arr2[idx3][idx2]
            row.append(num)
        answer.append(row)
                
    return answer

 

def solution(s):
    answer = []
    s_sp = s.split()
    s_list = list(map(int, s_sp))
    
    s_answer = sorted(s_list)
    answer.append(str(s_answer[0]))
    answer.append(str(s_answer[-1]))
    
    return " ".join(answer)

+ Recent posts