Problem: If you are a computer user, you should have seen pictures drawn with ASCII characters. Such a picture may not look as good as GIF or Postscript pictures, but is much easier to handle. ASCII pictures can easily be drawn using text editors, and can convey graphical information using only text-based media. Program s extracting information from such pictures may be useful.

We are interested in simple pictures of trapezoids, consisting only of asterisk('*') characters and blank spaces. A trapezoid (trapezium in the Queen's English) is a four-side polygon where at least one pair of its sides is parallel. Furthermore, the picture in this problem satisfies the following conditions.

1. All the asterisks in the picture belong to sides of some trapezoid.
2. Two sides of a trapezoid are horizontal and the other two are vertical or incline 45 degrees.
3. Every side is more than 2 characters long.
4. Two distinct trapezoids do not share any asterisk characters.
5. Sides of two trapezoids do not touch. That is, asterisks of one trapezoid do not appear in eight neighbors of asterisks of a different trapezoid. For example, the following arrangements never appear.




****    |    ****         |   ******
*  *    |    *   * ***    |   *   *
****    |    ******* *    |   ****
****       |          ***    |       ****
*  *       |                 |       *  *
****       |                 |       ****


Some trapezoids may appear inside others. For example, the following is a valid picture.


*********
*       *
* ***   *
* *  *  *
* ***** *
*       *
*********


Your task is to recognize trapezoids in the picture and to calculate the area of each trapezoid. The area of a trapezoid is the number of characters on or inside its four sides, including the areas of the trapezoids inside it, if any.



Input

The input contains several descriptions of pictures. Each of then starts with a line containing an integer h (1 ≤ h ≤ 1000), where h is the height (number of lines) of the picture. Each line of the picture consists only of asterisk and space characters, and contains less than 80 characters. The lines of the picture do not necessarily have the same length and may contain redundant space characters at the end. After the last picture, and integer zero terminates the input.

Output

For each picture, your program should produce output lines each containing two integers m and n is this order, which means there are n trapezoids of area m in the picture. output lines for one picture should be in ascending order on m and count all the trapezoids in the picture.

Output lines for two pictures should be separated by a line containing ten hyphen ('-') characters. This separator line should not appear before the output for the first picture nor after the output for the last.

Examples

Input

7
********
*      *
* ***  *
* * *  *
* ***  *
*      *
********
9

***
*  *
*****     *****
          *   *
    ***   *****
   * *
  * *
 ***
11
    ****                                      *******************
   *   *  *********                          *                  *
  ******  *       *    ****                 *  *********        *
          * ***   *   *  *                 *  *         *       *
***       * *  *  *  ****  *******        *  *  *** ***  *      *
* *       * ***** *         *   *        *  *   * *  * *  *     *
***       *       *          ***        *  *    ***   ***  *    *
          *********                    *  *                 *   *
                                      *  *********************  *
                                     *                          *
                                    *****************************
0


Output

9 1
56 1
----------
12 2
15 1
----------
9 3
12 2
15 2
63 1
105 1
264 1


Input

7
********
*      *
* ***  *
* * *  *
* ***  *
*      *
********
9

***
*  *
*****     *****
*   *
***   *****
* *
* *
***
11
****                                      *******************
*   *  *********                          *                  *
******  *       *    ****                 *  *********        *
* ***   *   *  *                 *  *         *       *
***       * *  *  *  ****  *******        *  *  *** ***  *      *
* *       * ***** *         *   *        *  *   * *  * *  *     *
***       *       *          ***        *  *    ***   ***  *    *
*********                    *  *                 *   *
*  *********************  *
*                          *
*****************************
0


Output

9 1
56 1
----------
12 2
15 1
----------
9 3
12 2
15 2
63 1
105 1
264 1

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main{
	//1036 start
	//1150 sample matched
	HashMap<Integer, Integer> areaList;
	P topleft, topright, bottomleft, bottomright;
	char [][] input;
	int [] vx = {0,1,1,1,0,-1,-1,-1};
	int [] vy = {1,1,0,-1,-1,-1,0,1};
	int n , xlen;
	
	//class
	class P{
		int x, y;
		public P(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	
	class C implements Comparable<C>{
		int area, count;

		public C(int area, int count) {
			this.area = area;
			this.count = count;
		}

		@Override
		public String toString() {
			return this.area + " " + this.count;
		}
		
		public int compareTo(C o){
			if(this.area < o.area) return -1;
			if(this.area > o.area) return 1;
			return 0;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		boolean flg = false;
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			if(! flg){
				flg = true;
			}
			else{
				System.out.println("----------");
			}
			sc.nextLine();
			input = new char[n][];
			for(int i = 0; i < n; i++){
				input[i] = sc.nextLine().toCharArray();
				//System.out.println(Arrays.toString(input[i]));
			}
			xlen = input[0].length;
			
			areaList = new HashMap<Integer, Integer>();
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < input[i].length; j++){
					if(input[i][j] == '*'){
						topleft = new P(j,i);
						topright = new P(j,i);
						bottomleft = new P(j,i);
						bottomright = new P(j,i);
						dfs(i,j);

						int res = getArea();
						if(areaList.containsKey(res)){
							areaList.put(res, areaList.get(res) + 1);
						}
						else{
							areaList.put(res, 1);
						}
					}
				}
			}
			
//			//debug
//			System.out.println("debug = " );
//			for(int ii = 0;ii < n ;ii++){
//				System.out.println(Arrays.toString(input[ii]));
//			}

			
			//print
			ArrayList<C> list = new ArrayList<C>();
			for(int key: areaList.keySet()){
				list.add(new C(key, areaList.get(key)));
			}
			
			Collections.sort(list);
			for(int i = 0; i < list.size(); i++){
				System.out.println(list.get(i));
			}
		}
	}

	private void dfs(int y, int x) {
		input[y][x] = ' ';
		
		if(y == bottomright.y){
			if(x < bottomleft.x){
				bottomleft.x = x;
			}
			else if(x > bottomright.x){
				bottomright.x = x;
			}
		}
		if(y > bottomright.y){
			bottomright.y = y;
			bottomleft.y = y;
			bottomleft.x = x;
			bottomright.x = x;
		}
		
		if(y == topright.y){
			if(x > topright.x){
				topright.x = x;
			}
		}
		
		for(int i = 0; i < vx.length; i++){
			int xx = x + vx[i];
			int yy = y + vy[i];
			if(! isOK(yy,xx)) continue;
			if(input[yy][xx] == '*'){
				dfs(yy,xx);
			}
		}
		
	}

	private boolean isOK(int y, int x) {
		if(0 <= y && y < n && 0 <= x && x < input[y].length) return true;
		return false;
	}

	private int getArea() {
		
		int top = topright.x - topleft.x + 1;
		int bottom = bottomright.x - bottomleft.x + 1;
		int height = bottomright.y - topright.y + 1;
//		System.out.println(topleft.x + "x= " + topright.x + "top= " + top + " bottom = " + bottom + " height = " + height);
//		System.out.println(bottomleft.x + " " + bottomright.x);
		return (top + bottom) * height / 2;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}