#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <map>
#define ll long long
#define endl '\n'
#define Pi 3.1415926535898
const int N = 2e6 + 5;
#define watch(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(),(v).end()
using namespace std;
// cout << fixed << setprecision(9);
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
void file() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 }; // dir array
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
int main() {
fast();
file();
int t;
cin >> t;
map <string, int > mp;
while (t--) {
string s;
cin >> s;
if (mp[s] == 0) {
cout << "ok" << endl;
mp[s] ++;
}
else {
string ch="" ;
for (int c = 1 ;; c++){
ch = to_string(c);
string t= s + ch ;
if (mp[t] == 0){
break;
}
}
int y = stoi(ch) ;
mp[s] = y ;
string x = to_string(mp[s]) ;
string str = s+x ;
cout << str<< endl ;
mp[str]++ ;
}
}
return 0;
}
Copy