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.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, m;
	int[][] a;
	int[] dx;
	int[] dy;
	int[] dx1={0, 0, -1, 1};
	int[] dy1={-1, 1, 0, 0};
	int[] dx2={1, 1, 0, -1, -1, -1, 0, 1};
	int[] dy2={0, 1, 1, 1, 0, -1, -1, -1};
	int swap;
	boolean[] wall;

	void run(){
		for(int k=0;; k++){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			if(k>0){
				println("----------");
			}
			sc.nextLine();
			m=0;
			String[] ss=new String[n];
			for(int i=0; i<n; i++){
				ss[i]=sc.nextLine();
				m=max(m, ss[i].length());
			}
			a=new int[n][m];
			for(int j=0; j<n; j++){
				for(int i=0; i<ss[j].length(); i++){
					a[j][i]=ss[j].charAt(i)=='*'?1:0;
				}
			}
			solve();
		}
	}

	void solve(){
		back();
		dx=dx1;
		dy=dy1;
		HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(a[j][i]==1){
					if(true){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}

					debug(i, j);
					int outline=0;
					int d=0;
					int x=i, y=j;
					for(;;){
						outline++;
						a[y][x]=0;
						boolean f=false;
						dx=dx2;
						dy=dy2;
						d=(d+5)%8;
						for(int k=0; k<dx.length; k++, d=(d+1)%8){
							int x2=x+dx[d];
							int y2=y+dy[d];
							if(x2>=0&&x2<m&&y2>=0&&y2<n&&a[y2][x2]==1){
								x=x2;
								y=y2;
								f=true;
								break;
							}
						}
						if(!f){
							break;
						}
					}
					/*
					 * for(d=0; d<8; d++){
					 * int x2=x+dx[d];
					 * int y2=y+dy[d];
					 * if(x2>=0&&x2<m&&y2>=0&&y2<n&&a[y2][x2]==0){
					 * x=x2;
					 * y=y2;
					 * break;
					 * }
					 * }
					 */

					dx=dx1;
					dy=dy1;

					if(true){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}
					if(i==47&&j==2&&false){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}

					debug();

					swap=-1;
					wall=new boolean[]{false, false, true};
					int area=bfs(x, y);
					if(true){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}
					swap=2;
					wall=new boolean[]{false, true, true};
					bfs(x, y);
					debug("outline", outline);
					debug("area", area);

					if(!map.containsKey(area)){
						map.put(area, 0);
					}
					map.put(area, map.get(area)+1);

					if(true){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}

					debug();

					if(i==47&&j==2&&false){
						for(int k=0; k<n; k++){
							debug(a[k]);
						}
					}

				}
			}
		}
		debug(map.entrySet());

		Integer[] is=map.keySet().toArray(new Integer[0]);
		sort(is);

		for(int key : is){
			println(key+" "+map.get(key));
		}

		for(int j=0; j<n; j++){
			debug(a[j]);
		}
	}

	void back(){
		dx=dx1;
		dy=dy1;
		swap=2;
		wall=new boolean[]{false, true, true};
		for(int j=0; j<n; j++){
			if(a[j][0]==0){
				bfs(0, j);
			}
			if(a[j][m-1]==0){
				bfs(m-1, j);
			}
		}
		for(int i=0; i<m; i++){
			if(a[0][i]==0){
				bfs(i, 0);
			}
			if(a[n-1][i]==0){
				bfs(i, n-1);
			}
		}
	}

	int bfs(int x, int y){
		debug(x, y);

		LinkedList<P> que=new LinkedList<P>();
		boolean[][] visited=new boolean[n][m];
		que.add(new P(x, y));
		visited[y][x]=true;
		int res=0;
		for(; !que.isEmpty();){
			P p=que.poll();
			// a[p.y][p.x]=2;
			if(swap>=0){
				a[p.y][p.x]=swap;
			}
			res++;
			for(int i=0; i<dx.length; i++){
				P q=new P(p.x+dx[i], p.y+dy[i]);
				if(q.x>=0&&q.x<m&&q.y>=0&&q.y<n&&!visited[q.y][q.x]
						&&!wall[a[q.y][q.x]]){
					que.add(q);
					visited[q.y][q.x]=true;
				}
			}
		}
		return res;
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		// System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}