#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  map<string, int> ma;
  cin >> N;
  string x, p;
  for (int i = 0; i < N; i++) {
    cin >> x;
    ma[x]++;
  }
  for (std::map<string, int>::iterator it = ma.begin(); it != ma.end(); it++) {
    cout << it->first << " x " << it->second << endl;
  }
}
