# Arup Guha
# 3/5/2022
# Solution to 2022 UCF HS Problem: Ovoo? What's That?

# Get number of cases.
nC = int(input())

# Go through each case.
for loop in range(1,nC+1):

    # Get length of input case.
    n = int(input())

    # My two counters.
    res = 0
    cur = 0

    # Case header.
    print("Clan #"+str(loop)+":")

    # Read in all the actions.
    for i in range(n):

        # Get this input.
        item = input()

        # We add 1 to our work accumulator to. 
        if item == "WORK":
            cur += 1
            

        # Time to process. So add to total and print.
        else:
            res += cur
            print(res)

    # After each case.
    print()
