#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  unordered_map<string, int> u;
  for (int i = 0; i < N; i++) {
    string str = " ";
    cin >> str;
    u[str]++;
  }
  for (auto i : u) {
    cout << i.first << " x " << i.second << endl;
  }
  return 0;
}
