#define ll long long
#define fr first
#define sc second
#define pb(x) push_back(x)
#define el '\n'
#define sz(container) ((ll) container.size())
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n, i;
string s, t;
unordered_map<string, ll> mp;
bool b;
cin >> n;
while (n--) {
cin >> s;
if (mp[s]) {
b = 1;
for (;b; ++mp[s]) {
t = s + to_string(mp[s]);
if (!mp[t]) {
cout << t << el;
mp[t] = 1;
b = 0;
}
}
} else {
cout << "ok\n";
mp[s] = 1;
}
}
return 0;
}
Copy