#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  map<string, long long int> a;
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a[s]++;
  }
  for (auto j = a.begin(); j != a.end(); j++) {
    cout << j->first << " "
         << "x"
         << " " << j->second << "\n";
  }
}
