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.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static final int MAX_WIDTH  = 80;
	public static final int MAX_HEIGHT = 1000;
	
	public static void trapezoid(final int ul_x, final int top_y, boolean[][] map, boolean[][] is_visited, TreeMap<Integer, Integer> ans){
		int ur_x = ul_x;
		
		do{
			is_visited[top_y][ur_x] = true;
			ur_x++;
			//System.out.println("t");
		}while(map[top_y][ur_x]);
		ur_x--;
		
		final int left_diff  = (ul_x != 0 && map[top_y + 1][ul_x - 1]) ? -1 : map[top_y + 1][ul_x + 1] ? 1 : 0; 
		final int right_diff =  map[top_y + 1][ur_x + 1] ? 1 : (ur_x != 0 && map[top_y + 1][ur_x - 1]) ? -1 : 0; 
		
		int bottom_y = top_y;
		int dl_x = ul_x;
		int dr_x = ur_x;
		
		//System.out.println(top_y + " " + ul_x + " " + ur_x);
		
		{
			int y = top_y;
			do{
				is_visited[y][dl_x] = true;
				y++;
				dl_x += left_diff;
				//System.out.println("l");
			}while(dl_x >= 0 && map[y][dl_x]);
			y--;
			dl_x -= left_diff;
			bottom_y = y;
		}
		
		{
			int y = top_y;
			//System.out.println(dr_x);
			do{
				is_visited[y][dr_x] = true;
				y++;
				dr_x += right_diff;
				//System.out.println(dr_x + " " + y);
			}while(dr_x >= 0 && map[y][dr_x]);
			y--;
			dr_x -= right_diff;
		}
		
		for(int x = dl_x; x <= dr_x; x++){
			is_visited[bottom_y][x] = true;
		}
		//System.out.println("t");
		
		final int up_length = ur_x - ul_x + 1;
		final int down_length = dr_x - dl_x + 1;
		final int y_length = bottom_y - top_y + 1;
		final int size = (up_length + down_length) * y_length / 2;
		
		//print(is_visited);
		
		if(!ans.containsKey(size)){
			ans.put(size, 1);
			/*
			if(size == 2){
				System.out.println(top_y + " " + bottom_y + " " + ul_x + " " + ur_x + " " + dl_x + " " + dr_x);
			}
			*/
		}else{
			ans.put(size, ans.get(size) + 1);
		}
		
		if(top_y + 2 < bottom_y){
			final int next_ul_x = left_diff  < 0 ? ul_x     : left_diff > 0 ? ul_x + 2 : (ul_x + 1);
			final int next_ur_x = right_diff < 0 ? ur_x - 2 : left_diff > 0 ? ur_x     : (ur_x - 1);
			final int next_dl_x = left_diff  < 0 ? dl_x - 2 : left_diff > 0 ? dl_x     : (dl_x + 1);
			final int next_dr_x = right_diff < 0 ? dr_x     : left_diff > 0 ? dr_x + 2 : (dr_x - 1);
			
			dfs(top_y + 1, bottom_y - 1, next_ul_x, next_ur_x, next_dl_x, next_dr_x, map, is_visited, ans);
		}
		
	}
	
	public static void print(boolean[][] is_visited){
		for(int i = 0; i < 11; i++){
			for(int j = 0; j < MAX_WIDTH; j++){
				System.out.print(is_visited[i][j] ? 'x' : ' ');
			}
			System.out.println();
		}
		System.out.println("----------------------------");
	}
	
	public static void dfs(final int top_y, final int bottom_y,
						   final int ul_x, final int ur_x, final int dl_x, final int dr_x,
						   boolean[][] map, boolean[][] is_visited,
						   TreeMap<Integer, Integer> ans){
		
		int first_x = ul_x;
		int last_x  = ur_x;
		//System.out.println(ul_x + " " + top_y);
		//System.out.println(ans);
		
		final int left_diff  = ul_x < dl_x ? 1 : ul_x > dl_x ? -1 : 0;
		final int right_diff = ur_x < dr_x ? 1 : ur_x > dr_x ? -1 : 0;
		
		for(int y = top_y; y <= bottom_y; y++){
			for(int x = first_x; x <= last_x; x++){
				//System.out.println(y + " " + x);
				
				if(is_visited[y][x]){
					continue;
				}else if(!map[y][x]){
					is_visited[y][x] = true;
				}else{
					trapezoid(x, y, map, is_visited, ans);
				}
			}
			
			first_x += left_diff;
			last_x += right_diff;
		}
	}
	
	
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		boolean[][] is_visited = new boolean[MAX_HEIGHT + 1][MAX_WIDTH + 1];
		boolean[][] map = new boolean[MAX_HEIGHT + 1][MAX_WIDTH + 1];
		TreeMap<Integer, Integer> ans = new TreeMap<Integer, Integer>();
		
		boolean first = true;
		while (true) {
			final int n = Integer.parseInt(sc.nextLine());
			
			if(n == 0){
				break;
			}
			
			if(!first){
				System.out.println("----------");
			}
			
			ans.clear();
			for(int i = 0; i < n; i++){
				Arrays.fill(is_visited[i], false);
				Arrays.fill(map[i], false);
			}
			
			for(int i = 0; i < n; i++){
				char[] input = sc.nextLine().toCharArray();
				
				for(int j = 0; j < input.length; j++){
					map[i][j] = input[j] == '*';
				}
			}
			/*
			for(int i = 0; i < n; i++){
				for(int j = 0; j < MAX_WIDTH; j++){
					System.out.print(map[i][j] ? '*' : ' ');
				}
				System.out.println();
			}
			*/
			dfs(0, n - 1, 0, MAX_WIDTH - 1, 0, MAX_WIDTH - 1, map, is_visited, ans);
			
			for(Entry<Integer, Integer> entry : ans.entrySet()){
				System.out.println(entry.getKey() + " " + entry.getValue());
			}
			
			if(first){
				first = false;
			}
		}
	}

}