Children in school are having fun instead of listening to the teacher. With their iPhone devices the children throw watermelons at each other on the Facebook social site.
The game started when Goran threw one watermelon at each of his friends during the first class that day. During subsequent classes, all children (including Goran) behaved like this:
If they had been hit by an odd number of watermelons during the previous class, they threw exactly one watermelon at each of their friends;
If they had been hit by an even number of watermelons (including zero), then they hit each of their friends with two watermelons.
The children are numbered through , Goran obviously being number . The friend relationships between the children are also known.
Write a program that will calculate the total number of watermelons thrown after classes.
Input Specification
The first line contains two integers and , the number of kids and classes.
Each of the following lines contains a string of characters 0
or 1
. The character in this
matrix is 1
if children and are friends.
No child will be their own friend. The input matrix will be symmetric.
Output Specification
Output the number of watermelons after classes.
Scoring
In test cases worth of points, will be at most .
Sample Input 1
4 1
0110
1001
1001
0110
Sample Output 1
2
Sample Input 2
4 2
0110
1001
1001
0110
Sample Output 2
14
Sample Input 3
5 3
01000
10110
01000
01001
00010
Sample Output 3
26
In the second example, Goran throws two watermelons during the first class. During the second class, children and each throw two watermelons at and each, while and throw one watermelon at and . A total of watermelons is thrown during the second class.
Comments
For the third sample, why is the output not 23?