#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
return (y + x % y) % y;
}
void fast()
{
std::ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef ONLINE_JUDGE
//freopen("crosses.in", "r", stdin);
//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
#endif
}
int main()
{
Mohammed_Atef_Hassan
set<pair<string,unsigned ll>>st;
int n;
cin>>n;
string t;unsigned ll num;
while(n--)
{
string s;
cin>>s;
t="",num=0;
for(int i=0;i<s.size();i++)
{
if(s[i]>='a'&&s[i]<='z')
t+=s[i];
else num=num*10+(s[i]-'0');
}
if(st.find({t,num})==st.end())
{
cout<<"ok";
}
else
{
bool valid=0;
num=num*10+0;
while(!valid)
{
num++;
if(st.find({t,num})==st.end())
{
cout<<t<<num;
valid=1;
}
}
}
st.insert({t,num});
cout<<finl;
}
}
Copy