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.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

//Trapezoids
public class Main{

	int h;
	char[][] map;
	int[] move = {-1,0,1};

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean f = true;
		while(true){
			h = sc.nextInt();
			if(h==0)break;
			if(!f)System.out.println("----------");
			f = false;
			Map<Integer, Integer> ans = new HashMap<Integer, Integer>();
			map = new char[h][];
			sc.nextLine();
			for(int i=0;i<h;i++)map[i]=sc.nextLine().toCharArray();
			for(int i=0;i<h;i++){
				for(int j=0;j<map[i].length;j++){
					if(map[i][j]!='*')continue;
					int a = 1;
					map[i][j] = ' ';
					int k = j+1;
					while(k<map[i].length&&map[i][k]=='*'){
						map[i][k++] = ' ';
						a++;
					}
					k--;
					int height = 1;
					int b = 1;
					for(int d=0;d<3;d++){
						int w = j+move[d];
						if(0<=w&&w<map[i+1].length&&map[i+1][w]=='*'){
							int y = i+1;
							while(y<h&&0<=w&&w<map[y].length&&map[y][w]=='*'){
								height++;
								map[y][w] = ' ';
								y++;
								w += move[d];
							}
							y--;
							w-=move[d];
							w++;
							while(w<map[y].length&&map[y][w]=='*'){
								b++;
								map[y][w] = ' ';
								w++;
							}
							w--;
							int dir = w<k?0:w==k?1:2;
							y = i+1;
							w = k + move[dir];
							while(w<map[y].length&&y<h&&map[y][w]=='*'){
								map[y][w] = ' ';
								y++;
								w+=move[dir];
							}
							break;
						}
					}
					int area = (a+b)*height/2;
					if(ans.containsKey(area)){
						ans.put(area, ans.get(area)+1);
					}
					else{
						ans.put(area, 1);
					}
				}
			}
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			for(Integer i:ans.keySet())q.add(i);
			while(!q.isEmpty()){
				int area = q.poll();
				System.out.println(area+" "+ans.get(area));
			}
		}
	}

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