#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i, t, c1 = 1, c2 = 1, c3 = 1, c4 = 1;
  string Si;
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> Si;
    if (Si == "AC")
      cout << Si << 'X' << c1++ << endl;
    else if (Si == "WE")
      cout << Si << 'X' << c2++ << endl;
    else if (Si == "TLE")
      cout << Si << 'X' << c3++ << endl;
    else if (Si == "RE")
      cout << Si << 'X' << c4++ << endl;
    else
      cout << Si << 'X' << 0 << endl;
  }
  return 0;
}
