After IOI Ilya decided to make a business.  He found a social network called "TheScorpyBook.com". It currently has N registered users. As in any social network two users can be friends. Ilya wants the world to be as connected as possible, so he wants to suggest friendship to some pairs of users. He will suggest user u to have a friendship with user v if they are not friends yet and there is a user w who is friends of both of them. Note that u, v and w are different users. Ilya is too busy with IPO these days, so he asks you to count how many friendship suggestions he has to send over his social network.
 

Input
The first line contains an integer number N — the number of users in the network. Next N lines contain N characters each denoting friendship relations. j^th character if the i^th lines equals one, if users i and j are friends and equals to zero otherwise. This relation is symmetric, i.e. if user a is friend of b then b is also a friend of a.
 

Output
Output a single integer — number of friendship suggestions Ilya has to send.
 

Constraints

1 ≤ N ≤ 2000

 

Example
Input:
4
0111
1000
1000
1000

Output:
6
 

Explanation
Each of users [2, 3, 4] should receive two friendship suggestions, while user 1 does not need any, since he already has all other users in his friend-list.
a = int (raw_input())
c= []
d= []

for i in range(a):
    now = raw_input()
    c.append(now)
    d.append(int(now,2))
    
i=0


for k in xrange(a):
    for j in xrange(k+1,a):
        if c[k][j]!='1':
            if int(d[k])&int(d[j]):
                i= i+2

print i