#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  unordered_map<string, int> res;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    res[s]++;
  }
  for (const auto& i : res) {
    cout << i.first << " x " << i.second << endl;
  }
}
