#include?<stdlib.h>
#include?<string.h>
int?main()
{
char?**a?;
int?n,i,j?;
char?*p;
char?str[20];
scanf("%d",?&n?);
a=(char?**)malloc(sizeof(char**)*n)?;
for(?i=0;i<n;i++?)
{
a[i]=(char?*)malloc(?20?)?;
scanf("%s",?a[i]?)?;
}
for(?j=0;j<n-1;j++?)
{
for(?i=0;i<n-j-1;i++?)
if?(?strcmp(a[i],a[i+1])>0?)
{
p=a[i];
a[i]=a[i+1];
a[i+1]=p;
}
}
printf("\n");
strcpy(str,a[0]);
free(a[0]);
j=1;
for(?i=1;i<n;i++?)
{
if?(?strcmp(a[i],str)==?0?)
j++;
else
{
printf("%s?%d\n",?str,j?);
strcpy(str,a[i]);
j=1;
}
free(a[i]);
}
printf("%s?%d\n",?str,j?);
free(a);
return?0;
}