#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<string, int> var;
  while (n--) {
    string s;
    cin >> s;
    var[s]++;
  }
  for (auto x : var) {
    cout << x.first << " x " << x.second << endl;
  }
}
