#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int nCase,n;
char str[105][1005],a[105];
scanf("%d",&nCase);
n=nCase;
for(int i=0;i<n;i++)
a[i]='0';
while(nCase--){
int j=1;
scanf("%s",str[n-nCase]);
for(int i=0;i<n-nCase;i++)
if(strcmp(str[i],str[n-nCase])==0){
a[i]++;
int d=strlen(str[n-nCase]);
str[n-nCase][d]=a[i];
printf("%s%c\n",str[i],a[i]);
j=0;
break;
}
if(j){
printf("OK\n");
}
}
return 0;
}
输入The first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 1000 characters, which are all lowercase Latin letters.输出Print n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.样例输入
4 abacaba acaba abacaba acab样例输出
OK OK abacaba1 OK