#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  map<string, long long> m;
  while (n--) {
    string s;
    cin >> s;
    m[s]++;
  }
  for (auto it = m.begin(); it != m.end(); it++) {
    cout << it->first << " ";
    cout << 'X' << " ";
    cout << it->second << " ";
  }
}
