Vectors
On the plane, given a set of points (x, y), where x and y – integer, 1 ≤ x ≤ M, 1 ≤ y ≤ N. With each point out exactly one of the following vectors: (-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1). Each vector connects one integer point of the plane with another. For example, if the point (2, 5) leaves the vector (1, 1), it connects this point with the (3, 6), but not vice versa.
Sequence of two or more points in the plane a_1, a_2, …, a_k is called a cycle if each point a_i is joined to a vector a_i_{+1} (1 ≤ i ≤ k-1), and a_k is connected with the vector a_1. Cycles are considered different if they differ by at least one vertex.
Write a program that according to the vectors coming out of the plane, finds a number of different cycles.
Input
The first line contains two integers N (1 ≤ N ≤ 100) and M (1 ≤ M ≤ 100). Each of the subsequent N lines contains M pairs (ie, 2×M numbers). A pair of x, which is in line y defines a vector at (x, y).
Ouput
Print one integer - the number of cycles formed by the vectors.