Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!

The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly started to put the chocolates on the cake. The value of Famil Door's happiness will be equal to the number of pairs of cells with chocolates that are in the same row or in the same column of the cake. Famil Doors's family is wondering what is the amount of happiness of Famil going to be?

Please, note that any pair can be counted no more than once, as two different cells can't share both the same row and the same column.


-----Input-----

In the first line of the input, you are given a single integer n (1 ≤ n ≤ 100) — the length of the side of the cake.

Then follow n lines, each containing n characters. Empty cells are denoted with '.', while cells that contain chocolates are denoted by 'C'.


-----Output-----

Print the value of Famil Door's happiness, i.e. the number of pairs of chocolate pieces that share the same row or the same column.


-----Examples-----
Input
3
.CC
C..
C.C

Output
4

Input
4
CC..
C..C
.CC.
.CC.

Output
9



-----Note-----

If we number rows from top to bottom and columns from left to right, then, pieces that share the same row in the first sample are:   (1, 2) and (1, 3)  (3, 1) and (3, 3)  Pieces that share the same column are:   (2, 1) and (3, 1)  (1, 3) and (3, 3)

Difficulty: interview

Starter code:

Solutions:
read = lambda: list(map(int, input().split()))
n = int(input())
a = [input() for i in range(n)]
f = lambda x: x * (x - 1) // 2
cnt = 0
for i in range(n):
    k1 = a[i].count('C')
    k2 = sum(a[j][i] == 'C' for j in range(n))
    cnt += f(k1) + f(k2)
print(cnt)


n = int(input())
rows = [0] * n
cols = [0] * n
for r in range(n):
    s = input()
    for c in range(n):
        if s[c] == "C":
            rows[r] += 1
            cols[c] += 1
ans = 0
for i in range(n):
    ans += rows[i] * (rows[i] - 1) // 2
    ans += cols[i] * (cols[i] - 1) // 2
print(ans)

n = int(input())
M = [[c == 'C' for c in input()] for i in range(n)]
K = [sum(M[i]) for i in range(n)]
L = [sum(M[i][j] for i in range(n)) for j in range(n)]
ans = sum(k*(k-1)//2 for k in K) + sum(l*(l-1)//2 for l in L)
print(ans)


n = int(input())
g, r, c = [input() for i in range(n)], [0] * n, [0] * n
for i in range(n):
    for j in range(n):
        if g[i][j] == 'C':
            r[i] += 1
            c[j] += 1
print(sum(x * (x - 1) // 2 for x in r + c))

n = int(input())
a = [['.'] * n for i in range(n)]
for i in range(n):
    a[i] = list(input())
c1 = 0
for i in range(n):
    c = 0
    for j in range(n):
        if a[i][j] == 'C':
            c += 1
    c1 += (c * (c - 1)) // 2
for i in range(n):
    c = 0
    for j in range(n):
        if a[j][i] == 'C':
            c += 1
    c1 += (c * (c - 1)) // 2
print(c1)

n = int(input())
pole = []
ans = 0
for i in range(n):
    s = input()
    h = 0
    for j in s:
        if j == 'C':
            h += 1
    ans += (h * (h - 1) // 2)
    pole.append(s)
for i in range(n):
    h = 0
    for j in range(n):
        if pole[j][i] == 'C':
            h += 1
    ans += (h * (h - 1) // 2)
print(ans)

n =int(input())
x=[[i for i in input()] for j in range(0,n)]
summ =0
for i in range(n):
	cur = 0
	for j in range(n):
		if (x[i][j]=='C'):
			cur+=1
	summ+=cur*(cur-1)//2
for j in range(n):
	cur = 0
	for i in range(n):
		if (x[i][j]=='C'):
			cur+=1
	summ+=cur*(cur-1)//2
print(summ)

n = int(input())

r = 0
stlpce = [0 for i in range(n)]
for i in range(n):
    line = input()
    riadok = 0
    for j, c in enumerate(line):
        if c == 'C':
            riadok += 1
            stlpce[j] += 1
    r += riadok * (riadok - 1) // 2

for stlpec in stlpce:
    r += stlpec * (stlpec - 1) // 2

print(r)


#!/usr/bin/env python3

N = int(input())
grid = [input() for _ in range(N)]

rows = [0 for _ in range(N)]
cols = [0 for _ in range(N)]

for i in range(N):
    for j in range(N):
        if grid[i][j] == 'C':
            rows[i] += 1
            cols[j] += 1
#

def blah(n):
    return n*(n-1)//2

total = sum(map(blah, rows)) + sum(map(blah, cols))
print(total)


n = int(input())
g = [list(input()) for _ in range(n)]

ret = 0

for i in range(n):
    for j in range(n):
        if g[i][j] != "C":
            continue
        for x in range(j+1, n):
            ret += g[i][x] == "C"
        for y in range(i+1, n):
            ret += g[y][j] == "C"

print(ret)


n = int(input())
l = [list(input()) for i in range(n)]
rows = [0 for i in range(n)]
cols = [0 for i in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if l[i][j] == 'C':
            rows[i] += 1
            cols[j] += 1

for i in range(n):
    ans += max(0, (rows[i])*(rows[i]-1)/2)
    ans += max(0, (cols[i])*(cols[i]-1)/2)
print(int(ans))


def f(n):
    return (n * (n - 1)) // 2
n = int(input())
ver = [0] * n
gor = [0] * n
for i in range(n):
    lst = input()
    for j in range(n):
        if lst[j] == 'C':
            gor[i] += 1
            ver[j] += 1
ans = 0
for i in ver:
    ans += f(i)
for i in gor:
    ans += f(i)
        
print(ans)


n = int(input())
arr = [list(input()) for i in range(n)]
ans = 0
for i in arr:
	s = 0
	for j in i:
		if(j == 'C'):
			s+=1
	ans += (s * (s-1))//2
for i in range(n):
	s = 0 
	for j in range(n):
		if(arr[j][i] == 'C'):
			s+=1
	ans += (s * (s -1 ))//2
print(ans)

def C(k):
    return (k*(k-1))//2

n=int(input())
r=[0 for i in range(n)]
c=[0 for i in range(n)]
for i in range(n):
    s=input()
    for j in range(n):
        if s[j]=='C':
            r[i]+=1
            c[j]+=1
ans=0
for i in range(n):
    ans+=(C(r[i])+C(c[i]))
print(ans)


n = int(input())
a = [0]*n
for i in range(n):
    a[i] = input().strip()
ans = 0
for i in range(n):
    s = 0
    for j in range(n):
        if a[i][j]=='C':
            s+=1
        # print(a[i][j])
    ans += s*(s-1)//2

for i in range(n):
    s = 0
    for j in range(n):
        if a[j][i]=='C':
            s+=1
    ans += s*(s-1)//2
print(ans)

n = int(input())
ans = 0
p = []
for i in range(n):
    p.append(list(input()))
    s = p[i].count('C')
    ans += s * (s - 1)
for i in range(n):
    col = 0
    for t in range(n):
        if p[t][i] == 'C':
             col += 1
    ans += col * (col - 1)
print(ans // 2)

        


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time


n   = int(input())
a   = [ 0 for i in range(n) ]
ans = 0

for i in range(n):
    str = input()
    m   = 0

    for j in range(n):
        if str[j] == 'C':
            m += 1
            a[j] += 1
    ans += m*(m-1)

start = time.time()

for i in range(n):
    ans += a[i]*(a[i]-1)

print(ans//2)
finish = time.time()
#print(finish - start)


n = int(input())
m = [input() for i in range(n)]
rows = [m[i].count('C') for i in range(n)]
columns = [0] * n
for j in range(n):
    for i in range(n):
        if m[i][j] == 'C':
            columns[j] += 1
ans = 0
for i in range(n):
    ans += (1 + (rows[i] - 1)) / 2 * (rows[i] - 1)
    ans += (1 + (columns[i] - 1)) / 2 * (columns[i] - 1)
print(int(ans))

n = int(input())
a = []
res = 0
for i in range(n):
    a += [input()]
for i in range(n):
    x = 0
    y = 0
    for j in range(n):
        if a[i][j] == 'C':
            x += 1
        if a[j][i] == 'C':
            y += 1
    res += x * (x-1) // 2 + y * (y-1) // 2
print(res)
            


import collections
import math

#n, m = map(int, input().split())
n = int(input())
t = [input() for _ in range(n)]

ans = 0
for i in range(n):
    x = t[i].count('C')
    #print(x)
    if x >= 2:
        ans += (x - 1) * x // 2
#print(ans)
for i in range(n):
    temp = 0
    for j in range(n):
        if t[j][i] == 'C':
            temp += 1
    if temp >= 2:
        ans += (temp - 1) * temp // 2
print(ans)


def C2( x ):
    if x <= 1:
        return 0
    return x*(x-1)//2

def __starting_point():

    n = int( input() )
    cake = []
    for i in range(n):
        cake.append( [c for c in input()] )

    #for line in cake:
    #    print(line)

    res = 0

    for i in range(n):
        num = 0
        for j in range(n):
            if cake[i][j] == "C":
                num += 1
        res += C2(num)

    for j in range(n):
        num = 0
        for i in range(n):
            if cake[i][j] == "C":
                num += 1
        res += C2(num)

    print(res)
__starting_point()

n = int(input())
maps = []
ans = 0
for i in range(n):
    maps.append(input())
    ans += (maps[-1].count('C') - 1) * maps[-1].count('C') // 2

for i in range(n):
    cnt = 0
    for j in range(n):
        if maps[j][i] == 'C':
            cnt += 1
    ans += (cnt - 1) * cnt // 2

print(ans)

n = int(input())
c = [0] * n
a = 0
for i in range(n):
    s = input()
    r = 0
    for j in range(n):
        if s[j] == 'C':
            r += 1
            c[j] += 1
    a += r * (r - 1) >> 1
for r in c:
    a += r * (r - 1) >> 1
print(a)


n = int(input())

rows = [0] * n
cols = [0] * n

def fact(num):
    res = 1
    while num > 1:
        res *= num
        num -= 1
    return res

def nC2(count):
    if count < 2:
        return 0
    elif count == 2:
        return 1
    return fact(count)//(2*fact(count-2))

for row in range(n):
    for col, ch in enumerate(input()):
        if ch == "C":
            rows[row] += 1
            cols[col] += 1

res = sum((nC2(num) for num in rows)) + sum((nC2(num) for num in cols))
print(res)


n = int(input())
cake = [input() for i in range(n)]
cake2 = [[0]*n for i in range(n)]
cakex = [0]*n
cakey = [0]*n
for i in range(n):
    for j in range(n):
         if cake[i][j] == "C":
             cake2[i][j] = 1
             cakex[i] += 1
             cakey[j] += 1

num = 0
for i in range(n):
    num += cakex[i]*(cakex[i]-1) // 2
    num += cakey[i]*(cakey[i]-1) // 2
print(num)