Problem11227--Triatrip

11227: Triatrip

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way or roundtrip for airline tickets to their customers, “Four Russians” offers the brand new idea — triatrip. Triatrip traveler starts in some city $A$, flies to some city $B$, then flies to some city $C$, and returns to the city $A$.
Now the managers of the agency started to wonder, how many different triatrips they can offer to their customers. Given a map of all possible flights, help them to find that out.

Input

The first line of the input file contains one integer numbers $n$ — the number of cities that are served by airlines that agree to sell their tickets via the agency $(3 ≤ n ≤ 1500)$.
The following n lines contain a sequence of $n$ characters each — the $j$-th character of the $i$-th line is ‘+’ if it is possible to fly from the $i$-th city to the $j$-th one, and ‘-’ if it is not. The $i$-th character of the $i$-th line is ‘-’.

Output

Output one integer number — the number of triatrips that the agency can offer to its customers.

Sample 1 Input

4
--+-
+--+
-+--
--+-

Sample 1 Output

2

HINT

CodeForces.

EDITORIAL

Source/Category