1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def subs(string, ret=['']):
    if len(string) == 0:
        return ret
    head, tail = string[0], string[1:]
    ret = ret + list(map(lambda x: x + head, ret))
    return subs(tail, ret)


def get_possibilities(string: str):
    tab = subs(string)
    solution = set()
    for e in tab:
        if e.count('L') == e.count('P') != 0 and e[0] != 'P':
            ok = True
            for i in range(1, len(e)):
                if e[0: i].count('L') < e[0: i].count('P'):
                    ok = False
            if ok:
                solution.add(e)
    return solution


n = int(input())
tab = list()
for i in range(n):
    tab.append(input())

for i in range(n):
    for j in range(n):
        print(len(get_possibilities(tab[i] + tab[j])), end=" ")
    print()