#include <string.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
char *id;
int full;
}* List;
int f(char * id,int i){
return ((int)(id[10]-'0')+i*i)%10;
}
int main(){
List A[10];
for(int i=0;i<10;i++){
A[i]=(List)malloc(sizeof(struct node));
A[i]->id=(char*)malloc(sizeof(char)*12);
A[i]->full=0;
}
char input[10000];
scanf("%s",input);
int t=0, m=0;
char id[12];
char a=input[t++];
while(a!='\n'&&a!='\0'){
if(a==','){
m=0;
}
else{
id[m++]=a;
}
if(m==11){
int i=0;
while(A[f(id,i)]->full){
i++;
}
strcpy(A[f(id,i)]->id,id);
A[f(id,i)]->full=1;
}
a=input[t++];
}
for(int i=0;i<10;i++){
if(i)printf(",");
if(A[i]->full){
printf("%s",A[i]->id);
}
else{
printf("0");
}
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct a{
char id[19];
struct a* next;
int num;
}* S;
int f(char * id){
long long t=0;
for(int i=0;i<18;i++){
t=t*10+(int)(id[i]-'0');
}
if(t<0)t=-t;
return t%10000;
}
int main(){
S A[10000];
for(int i=0;i<10000;i++){
A[i]=(S)malloc(sizeof(struct a));
A[i]->next=NULL;
A[i]->num=0;
}
int M,N;
scanf("%d%d",&M,&N);
for(int i=0;i<M;i++){
char id[19];
int n;
scanf("%s%d",id,&n);
if(n<N)n=N;
S O=A[f(id)];
while(O!=NULL&&strcmp(O->id,id)){
O=O->next;
}
if(O==NULL){
O=(S)malloc(sizeof(struct a)) ;
strcpy(O->id,id);
O->next=A[f(id)]->next;
A[f(id)]->next=O;
O->num=n;
}
else{
O->num+=n;
}
}
scanf("%d",&N);
for(int i=0;i<N;i++){
char id[19];
scanf("%s",id);
S O=A[f(id)];
while(O!=NULL&&strcmp(O->id,id)){
O=O->next;
}
if(O==NULL){
printf("No Info\n");
}
else{
printf("%d\n",O->num);
}
}
return 0;
}