Byteasar loves trekking in the hills. During his hikes he explores every ridge and valley nearby. To plan a trip and know how long it will take, he needs to know how many ridges and how many valleys lie in the area he is about to visit. Your job is to help him.
Byteasar gives you a map of his next expedition. The map is an n×n square. For every field (i,j) of the square (with i,j∈{1,…,n}) its height w(i,j) is given.
Two fields are adjacent when they share a side or a corner. In other words, field (i,j) is adjacent to (i−1,j−1), (i−1,j), (i−1,j+1), (i,j−1), (i,j+1), (i+1,j−1), (i+1,j) and (i+1,j+1), whenever those fields still lie on the map.
A set of fields S forms a ridge (respectively a valley) when:
In particular, if every field on the map has the same height, all of them together form both a ridge and a valley.
Determine the number of ridges and the number of valleys in the landscape described by the map.
The first line contains one integer n (2≤n≤1000), the size of the map. Each of the next n lines describes one row of the map: line i+1 (for i∈{1,…,n}) contains n integers w(i,1),…,w(i,n) (0≤w(i,j)≤109), separated by single spaces, the heights of the fields in row i.
Print a single line with two integers separated by one space: the number of ridges followed by the number of valleys in the landscape described by the map.


In the figures above the ridges are drawn with a solid line and the valleys with a dashed line.