def dfs(fld, check, n, m, depth)
  ok = true
  n.times do |y|
    m.times do |x|
      if check[y][x] == depth && fld[y][x] == '*'
        l = r = x
        loop do
          check[y][r] = depth + 1
          break if fld[y][r + 1] != '*'
          r += 1
        end
        ml = mr = -2
        (l-1..r+1).each do |i|
          ml = i - l if fld[y + 1][i] == '*' && ml == -2
          mr = i - r if fld[y + 1][i] == '*' && ml != -2
        end
        yy = y + 1; xl = l + ml; xr = r + mr
        loop do
          check[yy][xl] = check[yy][xr] = depth + 1
          (xl+1...xr).each{ |k| check[yy][k] = depth + 2 }
          if fld[yy + 1][xl + ml] != '*'
            (xl+1...xr).each{ |k| check[yy][k] = depth + 1 }
            break
          end
          yy += 1; xl += ml; xr += mr
        end
        s = ((r - l + 1) + (xr - xl + 1)) * (yy - y + 1) / 2
        $ret[s] ||= 0
        $ret[s] += 1
        ok = false
      end
    end
  end
  return true if ok
  return true if dfs(fld, check, n, m, depth + 2)
end

l = false
while n = gets.to_i
  break if n == 0
  if l
    10.times{ print '-' }
    puts
  end
  l = true
  fld = n.times.map{ gets.chomp.split('').unshift(' ').push(' ') }
  m = fld.map{ |f| f.size }.max
  fld.each{ |f| (m - f.size).times{ f.push(' ') } }
  fld = [ [' '] * m, *fld, [' '] * m ]
  $ret = {}
  check = (n+2).times.map{ [0] * m }
  dfs(fld, check, n+2, m, 0)
  $ret.sort.each{ |k, v| puts "#{k} #{v}" }
end