#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <set>
#include <cstdio>
#include <string>
#include <stack>
#include <map>
#include <sstream>
#define ll long long
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()
using namespace std;
void AIA()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void file()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int OO = 1e9 + 7;
const long double PI = acos(-1);
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dx4[] = {0, 1, 0, -1};
int dy[] = {1, -1, 0, 0, 1, -1, -1, 1}, dy4[] = {1, 0, -1, 0};
int main()
{
// Verify Your thought before Coding.
AIA();
file();
int n;
cin >> n;
map<string, int> mp;
while (n--)
{
string s;
cin >> s;
if (!mp.count(s))
{
cout << "ok\n";
mp[s] = 1;
}
else
{
mp[s + "" + to_string(mp[s])] = 1;
cout << s << mp[s] << "\n";
int a = mp[s];
while (mp.count(s + "" + to_string(a)))
a++;
mp[s] = a;
}
}
}
Copy