Problem: Offering the ABBYY Cup participants a problem written by the Smart Beaver is becoming a tradition. He proposed the following problem.

You are given a monochrome image, that is, an image that is composed of two colors (black and white). The image is given in raster form, that is, as a matrix of pixels' colors, and the matrix's size coincides with the size of the image.

The white color on the given image corresponds to the background. Also, the image contains several black geometric shapes. It is known that the image can contain only two types of shapes: squares and circles. Your task is to count the number of circles and the number of squares which the given image contains.

The squares on the image can be rotated arbitrarily. In addition, the image can possibly contain some noise arranged as follows: each pixel of the original image can change its color to the opposite with the probability of 20%.

<image> An example of an image that has no noise and the sides of the squares are parallel to the coordinate axes (two circles and three squares).  <image> An example of an image that has no noise and the squares are rotated arbitrarily (two circles and three squares).  <image> An example of an image that has noise and the squares are rotated arbitrarily (one circle and three squares). 

Input

The first input line contains a single integer n (1000 ≤ n ≤ 2000), which is the length and the width of the original image. 

Next n lines describe the matrix of colors of the image pixels. The i-th line contains exactly n integers aij (0 ≤ aij ≤ 1), separated by spaces. Value of aij = 0 corresponds to a white pixel and aij = 1 corresponds to a black one. 

It is guaranteed that the lengths of the sides of the squares and the diameters of the circles in the image are at least 15 pixels, and the distance between any two figures is at least 10 pixels. It is also guaranteed that a human can easily calculate the number of circles and squares in the original image. The total number of figures in the image doesn't exceed 50.

The input limitations for getting 20 points are: 

  * These test cases have no noise and the sides of the squares are parallel to the coordinate axes. 



The input limitations for getting 50 points are: 

  * These test cases have no noise, but the squares are rotated arbitrarily. 



The input limitations for getting 100 points are: 

  * These test cases have noise and the squares are rotated arbitrarily. 

Output

Print exactly two integers, separated by a single space — the number of circles and the number of squares in the given image, correspondingly.

Examples

Note

You are given a sample of original data for each difficulty level. The samples are available at http://codeforces.ru/static/materials/contests/178/e-samples.zip .

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
/*
 *	
 *	E.java
 *	Written by Andy Huang: 9:57:38 AM Apr 28, 2012
 */
public class E {
	static boolean img[][];
	static final int d[][] = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
	
	static void solve() {
		int n = in.nInt();
		img = new boolean[n + 2][n + 2];
		int sq = 0;
		int cir = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n ; j++)
				if (in.nInt() == 1)
					img[i][j] = true;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (!img[i][j])
					continue;
				int rowlen = 0;
				int temp = j;
				while (img[i][temp]){
					temp++;
					rowlen++;
				}
				temp = i;
				int collen = 0;
				while (img[temp][j]){
					temp++;
					collen++;
				}
				//pln(rowlen+","+collen);
				if (rowlen == collen){
					sq++;
					for (int k = i; k < i + collen; k++)
						for (int l = j; l < j + rowlen; l++)
							img[k][l] = false;
				}
				else{
					cir++;
					int start = j - (collen >> 1);
					for (int k = i; k < i + collen; k++)
						for (int l = start; l < start + collen; l++)
							img[k][l] = false;
				}
			}
		}
		out.append(cir);
		out.append(' ');
		out.appendln(sq);
	}
	
	public static void main(String[] args) {
		in = new Input();
		out = new Output();
		solve();
		out.print();
	}

	static Output out;
	static Input in;

	static void pln(Object o) {
		System.out.println(o);
	}

	static void pf(Object o) {
		System.out.print(o);
	}

}

final class Point extends java.awt.Point {
	private static final long serialVersionUID = -5276940640259749850L;

	public Point(int a, int b) {
		super(a, b);
	}

	public Point(Point p) {
		super(p);
	}

	public Point() {
		super();
	}

	public String toString() {
		return "(" + x + "," + y + ")";
	}
}

final class Input {
	private java.io.BufferedReader reader;
	private java.util.StringTokenizer tokenizer;

	public Input() {
		reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
//		try {
//			reader = new BufferedReader(new FileReader("input.txt"));
//		}
//		catch (FileNotFoundException e) {
//		}
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			}
			catch (java.io.IOException e) {
				throw new RuntimeException("Input Error");
			}
		}
		return tokenizer.nextToken();
	}

	public String nLine() {
		try {
			return reader.readLine();
		}
		catch (java.io.IOException e) {
			throw new RuntimeException(e);
		}
	}

	public long nLong() {
		return Long.parseLong(next());
	}

	public int nInt() {
		return Integer.parseInt(next());
	}

	public double nDouble() {
		return Double.parseDouble(next());
	}

}

final class Output {
	public StringBuilder buffer;

	Output() {
		buffer = new StringBuilder();
	}

	Output(int size) {
		buffer = new StringBuilder(size);
	}

	void print() {
		System.out.print(buffer.toString());
	}

	void flush() {
		System.out.flush();
	}

	<T> void append(T obj) {
		buffer.append(obj);
	}

	<T> void appendln(T obj) {
		append(obj);
		append('\n');
	}

	void delete(int index) {
		buffer.deleteCharAt(index);
	}

}