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 CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

char in[1002][1001];
map<int, int> ans;

int N;

inline bool valid(int x, int y) {
  return 0<=x && x<1001 && 0<=y && y<N;
}

int getlen_yaxis(int x, int y) {
  
  int top_y = y;
  while(top_y >= 0 && in[top_y][x] == '*') { top_y --; }
  top_y ++;
  int bottom_y = y;
  while(bottom_y < N && in[bottom_y][x] == '*') { bottom_y ++; }
  bottom_y --;
  
  return bottom_y - top_y + 1;
}

int getlen_xaxis(int x, int y) {
  
  int left_x = x;
  while(left_x >= 0 && in[y][left_x] == '*') { left_x --; }
  left_x ++;
  int right_x = x;
  while(right_x < 1001 && in[y][right_x] == '*') { right_x ++; }
  right_x --;

  return right_x - left_x + 1;
}

int const dx[8] = {-1,0,1,0,-1,1,1,-1};
int const dy[8] = {0,-1,0,1,-1,-1,1,1};

void move_to_xaxis(int& x, int& y) {
  
  int dir;
  if(x-1>=0 && in[y][x-1] == '*') { dir = 0; }
  else { dir = 2; }
  
  bool turn = 0;
  while(1) {
    int nx = x+dx[dir], ny = y+dy[dir];
    if(valid(nx, ny) && in[ny][nx] == '*') {
      if(turn && (x+1 == nx || x-1 == nx) && y == ny) return;
      x = nx, y = ny;
    }
    else {
      rep(k, 8) {
	nx = x+dx[k], ny = y+dy[k];
	if(x-dx[dir] == nx && y-dy[dir] == ny) continue;
	if(valid(nx, ny) && in[ny][nx] == '*' && valid(nx+dx[k], ny+dy[k]) && in[ny+dy[k]][nx+dx[k]] == '*') {
	  x = nx, y = ny; dir = k; turn = 1; break;
	}
      }
    }
  }
  
}

void move_to_yaxis(int& x, int& y) {
  
  int dir;
  if(y-1>=0 && in[y-1][x] == '*') { dir = 1; }
  else { dir = 3; }
  
  bool turn = 0;
  while(1) {
    int nx = x+dx[dir], ny = y+dy[dir];
    if(valid(nx, ny) && in[ny][nx] == '*') {
      if(turn && (y+1 == ny || y-1 == ny) && x == nx) return;
      x = nx, y = ny;
    }
    else {
      rep(k, 8) {
	nx = x+dx[k], ny = y+dy[k];
	if(x-dx[dir] == nx && y-dy[dir] == ny) continue;
	if(valid(nx, ny) && in[ny][nx] == '*' && valid(nx+dx[k], ny+dy[k]) && in[ny+dy[k]][nx+dx[k]] == '*') {
	  x = nx, y = ny; dir = k; turn = 1; break;
	}
      }
    }
  }
  
}

void calc_area_xaxis(int x, int y) {
  int len1 = getlen_xaxis(x, y);
  int tmp_y = y;
  move_to_xaxis(x, y);
  int len2 = getlen_xaxis(x, y);
  ans[(len1+len2)*abs(y-tmp_y+1)/2] ++;
}

void calc_area_yaxis(int x, int y) {
  int len1 = getlen_yaxis(x, y);
  int tmp_x = x;
  move_to_yaxis(x, y);
  int len2 = getlen_yaxis(x, y);
  ans[(len1+len2)*abs(x-tmp_x+1)/2] ++;
}

void eraser(int x, int y, int dir) {
  
  in[y][x] = ' ';
  
  while(1) {
    int nx = x+dx[dir], ny = y+dy[dir];
    if(valid(nx, ny) && in[ny][nx] == '*') {
      in[ny][nx] = ' ';
      x = nx, y = ny;
    }
    else {
      bool changed = 0;
      rep(k, 8) {
	int nx = x+dx[k], ny = y+dy[k];
	if(valid(nx, ny) && in[ny][nx] == '*' && valid(nx+dx[k], ny+dy[k]) && in[ny+dy[k]][nx+dx[k]] == '*') {
	  in[ny][nx] = ' ';
	  x = nx, y = ny;
	  dir = k; changed = 1; break;
	}
      }
      if(!changed) {
	rep(k, 8) {
	  int nx = x+dx[k], ny = y+dy[k];
	  if(!valid(nx, ny)) continue;
	  in[ny][nx] = ' ';
	}
	break;
      }
    }
  }
}


int main() {

  while(cin >> N && N) {
    ans.clear();
    memset(in, 0, sizeof in);
    cin.ignore();
    rep(i, N) {
      rep(j, 1001) {
	char c; scanf("%c", &c);
	if(c == '\n') { break; }
	in[i][j] = c;
      }
    }
    
    rep(i, N) {
      rep(j, 1001) {
	if(in[i][j] == 0) break;
	if(in[i][j] == '*' && (j-1>=0 && in[i][j-1] == '*')) {
	  calc_area_xaxis(j, i);
	  eraser(j, i, 0);
	}
	else if(in[i][j] == '*' && (i-1>=0 && in[i-1][j] == '*' )) {
	  calc_area_yaxis(j, i);
	  eraser(j, i, 1);
	}
      }
    }
    static bool flag = 0;
    if(flag) cout << "----------\n";
    flag = 1;
    map<int, int>::iterator it = ans.begin();
    for(; it!=ans.end(); it++) {
      cout << it->first << ' ' << it->second << endl;
    }
  }
  
  return 0;
}