#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define INF INT_MAX
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define nl "\n"
using namespace std;
const ll MOD = 1e9+7;
const int mxN = 2e5+1;
int main()
{
FAST
//==================
map<string,int> m;
ll n; cin >> n;
for(int i=0;i<n;i++){
string s; cin >> s;
if(m[s] == 0){
cout << "ok\n";
m[s]++;
}else{
string k = s + to_string(m[s]);
while(m[k]!=0){
k = s + to_string(m[s]);
m[s]++;
}
m[k]++;
cout << k << nl;
}
}
}
Copy