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 <iostream>
#include <algorithm>
#include <vector>
#define WMAX 100
#define HMAX 1000
#define INF  9999999
using namespace std;

string M[HMAX];
int h;

int ha;
int hb;
int wa;
int wb;

bool visited[HMAX][WMAX];
int flag45_1, flag45_2;

class A {
public:
  int S;
  int N;
  A(int S, int N) {
    this->S = S;
    this->N = N;
  }
  bool operator <(const A &a) const {
    return S < a.S;
  }
};

void rec(int x, int y, int bi) {
  static int dx[8] = {1,1,0,-1,-1,-1, 0, 1};
  static int dy[8] = {0,1,1, 1, 0,-1,-1,-1};
  ha = min(ha, y);
  hb = max(hb, y);
  wa = min(wa, x);
  wb = max(wb, x);

  for(int i = 0; i < 8; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(ny < 0 || ny >= h) continue;
    if(nx < 0 || nx >= M[ny].length()) continue;

    if(visited[ny][nx]) continue;
    if(M[ny][nx] != '*') continue;
    visited[ny][nx] = true;
    if(i != bi) {
      if(i == 1 || i == 5) flag45_1++;
      if(i == 3 || i == 7) flag45_2++;
    }
    rec(nx, ny, i);
  }
}

void solve() {
  int cnt[WMAX*HMAX];
  int smax, smin;
  vector<A> V;
  smax = -INF;
  smin = INF;
  for(int i = 0; i < WMAX*HMAX; i++) cnt[i] = 0;
  for(int i = 0; i < HMAX; i++) {
    for(int j = 0; j < WMAX; j++) {
      visited[i][j] = false;
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < M[i].length(); j++) {
      if(!visited[i][j] && M[i][j] == '*') {
	ha = wa = INF;
	hb = wb = -INF;
	flag45_1 = flag45_2 = 0;
	visited[i][j] = true;
	//cout << i << ", " << j << endl;
	rec(j, i, -1);
	//cout << "(" << ha << ", " << wa << ", " << hb << ", " << wb << ")";
	int nh = hb-ha+1;
	int nw = wb-wa+1;
	int S;
	S = nh * nw;
	//cout << nh << "*" << nw << "=" << S << endl;
	if(!flag45_1 && !flag45_2) {
	} else if(flag45_1 == 2 || flag45_2 == 2){
	  S -= (nh-1) * nh;
	} else if(flag45_1 && flag45_2) {
	  S -= (nh-1) * nh;
	} else if(flag45_1 + flag45_2 == 1) {
	  S -= (nh-1) * nh / 2;
	}
	cnt[S]++;
	smax = max(smax, S);
	smin = min(smin, S);
      }
    }
  }

 
  for(int i = smin; i <= smax; i++) {
    if(cnt[i]) {
      V.push_back(A(i, cnt[i]));
    }
  }

  sort(V.begin(), V.end());
  for(int i = 0; i < V.size(); i++) {
    cout << V[i].S << " " << V[i].N << endl;
  }
}

int main() {
  bool first = true;
  while((cin >> h) && h != 0) {
    getchar();
    for(int i = 0; i < h; i++) {
      getline(cin, M[i]);
    }

    if(first) first = false;
    else      cout << "----------" << endl;

    solve();
  }
}