def dfs(fld, check, n, m, depth)
  ok = true
  n.times do |r|
    m.times do |c|
      if check[r][c] == depth && fld[r][c] == '*'
        q = []
        mem = n.times.map{ [] }
        check[r][c] = depth + 1
        cnt = 1
        q << [r, c]
        mem[r] << c
        until q.empty?
          r, c = q.shift
          (-1..1).each do |yy|
            (-1..1).each do |xx|
              next if yy == 0 && xx == 0
              y = r + yy; x = c + xx
              if check[y][x] != depth + 1 && fld[y][x] == '*'
                check[y][x] = depth + 1
                cnt += 1
                q << [y, x]
                mem[y] << x
              end
            end
          end
        end
        mem.each_with_index do |m, i|
          if m.size == 2
            m[0], m[1] = m[1], m[0] if m[0] > m[1]
            (m[0]+1...m[1]).each{ |k| check[i][k] = depth + 2 }
            cnt += m[1] - m[0] - 1
          end
        end
        $ret[cnt] ||= 0
        $ret[cnt] += 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_by{ |k, v| [-v, k] }.each{ |k, v| puts "#{k} #{v}" }
end