#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt = 0;
  map<string, int> dict;
  int n;
  cin >> n;
  for (string s; n--; dict[s]++) {
    cin >> s;
    if (dict[s] + 1) {
      cnt++;
    }
    cout << s << " "
         << "x"
         << " " << cnt / 2 << endl;
  }
}
