int main()
{
	int num[27] = {0},no[27][1000]={0};
	char s[27],ls;
	int l,i,max,t,j,flag,n,w;
	cin >> t;
	for (i = 1;i <= t;i++)
	{
		cin >> n >> s;
		l =	strlen (s);
		for (j = 0;j <= l-1;j++)
		{
			w = s[j] - 'A' + 1;
			num[w] ++;
			no[w][num[w]] = n;
		}
	}
	max = 0;
	for (i = 1;i <= 26;i++)
		if (num[i] > max)
		{
			max = num[i];
			flag = i;
		}
	ls = (char) 64+flag;
	cout << ls << endl << num[flag] << endl;
	for (i = 1;i <= num[flag];i++)
		cout << no[flag][i] << endl;
	cin >> w;
    return 0;
}


int main()
{
	int m,a[1000],i,n,j,k;
	scanf("%d",&m);
	char b[1000][27];
	int count[26]={0};
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&a[i],b[i]);
	}
	for(i=0;i<m;i++)
	{
		n=strlen(b[i]);
		for(j=0;j<n;j++)
		{
			for(k=0;k<26;k++)
			{
				if(b[i][j]==k+65)count[k]++;
			}
		}
	}
	int max,maxk;
	max=count[0];
	maxk=0;
	for(k=0;k<26;k++)
	{
		if(count[k]>max)
		{
			max=count[k];
			maxk=k;
		}
	}
	char mauthor;
	mauthor=maxk+65;
	printf("%c\n%d\n",mauthor,max);
	for(i=0;i<m;i++)
	{
		n=strlen(b[i]);
		for(j=0;j<n;j++)
		{
				if(b[i][j]==mauthor)
				{
					printf("%d\n",a[i]);
					break;
				}

		}
	}
	return 0;
}


struct index
{
	int num;
	char wr[26];
};
int main()
{
	int n,a[26],*pr,max;
	char s[26],*sp,*pt,temp;
	for(pr=a;pr<a+26;pr++)
	{
		*pr=0;
	}
	sp=s;
	*sp=65;
	for(sp=s+1;sp<s+26;sp++)
	{
		*sp=*(sp-1)+1;
	}
	struct index *p;
	scanf("%d",&n);
	struct index *ind=(struct index*)malloc(sizeof(struct index)*n);
	for(p=ind;p<ind+n;p++)
	{
		scanf("%d %s",&p->num,p->wr);
	}
	for(p=ind;p<ind+n;p++)
	{
		for(pt=(*p).wr;pt<(*p).wr+26;pt++)
		{
			for(pr=a,sp=s;sp<s+26;sp++,pr++)
			{
				if(*pt==*sp)
				{
					(*pr)++;
				}
			}
		}
	}
	max=*a;
	temp=65;
	for(pr=a,sp=s;pr<a+26;pr++,sp++)
	{
		if(*pr>max)
		{
			max=*pr;
			temp=*sp;
		}
	}
	for(pr=a,sp=s;sp<s+26;sp++,pr++)
	{
		if(*pr==max)
		{
			printf("%c\n%d\n",*sp,*pr);
		}
	}
	for(p=ind;p<ind+n;p++)
	{
		for(pt=(*p).wr;pt<(*p).wr+26;pt++)
		{
			if(*pt==temp)
			{
				printf("%d\n",(*p).num);
			}
		}
	}
	free(ind);
	return 0;
}


struct info
{
	short int num;
	char author[27];
};

int main()
{
	char findoutmax(struct info a[],int n,int *pt);
	void detect(struct info b[],char writter,int nn);
	char figure;
	int i,n_book,max,*p;
	struct info book[999];
	scanf("%d",&n_book);
	for (i=0;i<n_book;i++)
	{
		scanf("%d %s",&book[i].num , &book[i].author);
	}
	p=&max;
	figure=findoutmax(book,n_book,p);
	printf("%c\n%d\n",figure,max);
	detect(book,figure,n_book);
	return 0;
}

char findoutmax(struct info a[],int n,int *pt)
{
	int i,j,sum[26]={0};
	for (i=0;i<n;i++)
	{
		for (j=0;a[i].author[j]!='\0';j++)
		{
			switch (a[i].author[j])
			{
			case 'A': sum[0]=sum[0]+1; break;
			case 'B': sum[1]=sum[1]+1; break;
			case 'C': sum[2]=sum[2]+1; break;
			case 'D': sum[3]=sum[3]+1; break;
			case 'E': sum[4]=sum[4]+1; break;
			case 'F': sum[5]=sum[5]+1; break;
			case 'G': sum[6]=sum[6]+1; break;
			case 'H': sum[7]=sum[7]+1; break;
			case 'I': sum[8]=sum[8]+1; break;
			case 'J': sum[9]=sum[9]+1; break;
			case 'K': sum[10]=sum[10]+1; break;
			case 'L': sum[11]=sum[11]+1; break;
			case 'M': sum[12]=sum[12]+1; break;
			case 'N': sum[13]=sum[13]+1; break;
			case 'O': sum[14]=sum[14]+1; break;
			case 'P': sum[15]=sum[15]+1; break;
			case 'Q': sum[16]=sum[16]+1; break;
			case 'R': sum[17]=sum[17]+1; break;
			case 'S': sum[18]=sum[18]+1; break;
			case 'T': sum[19]=sum[19]+1; break;
			case 'U': sum[20]=sum[20]+1; break;
			case 'V': sum[21]=sum[21]+1; break;
			case 'W': sum[22]=sum[22]+1; break;
			case 'X': sum[23]=sum[23]+1; break;
			case 'Y': sum[24]=sum[24]+1; break;
			case 'Z': sum[25]=sum[25]+1; break;
			}
		}
	}
	j=0;
	for (i=1;i<26;i++)
	{
		if (sum[j]<sum[i]) j=i;
	}
	*pt=sum[j];
	return (65+j);
}

void detect(struct info b[],char writter,int nn)
{
	int i,j;
	for (i=0;i<nn;i++)
	{
		for (j=0;b[i].author[j]!='\0';j++)
		{
			if (b[i].author[j]==writter)
			{
				printf("%d\n",b[i].num);
			}
		}
	}
}


void main()
{
    int len[1000];
	int b[26];
	int a[1000];
	char str[1000][26];
	int m,i,j,max,num;
	char c;
	int pos,temp;

    scanf("%d",&m);
	for(i=0;i<26;i++)
		b[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d ",&a[i]);
		scanf("%s",str[i]);
		len[i]=strlen(str[i]);
		for(j=0;j<len[i];j++)
		{
			temp=str[i][j]-'A';
			b[temp]++;
		}
	}

    max=b[0];
	pos=0;
	for(i=1;i<26;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
			pos=i;
		}
	}
    c=pos+'A';
    printf("%c\n",c);
	printf("%d\n",max);
	num=0;
    	for(i=0;i<m;i++)
		for(j=0;j<len[i];j++)
			if(str[i][j]==c)
			{
				num++;
				if(num<max)
					printf("%d\n",a[i]);
				else printf("%d",a[i]);
			}
}


int main() {
    struct book1 {
        int num;
        char author[20];
    } book[999];
    int time[26]={0};
    int n, i, j, k, maxi, sign=0;
    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%d%s", &book[i].num, book[i].author);
    }
    for (i=0;i<n;i++) {
        for (j=0;book[i].author[j]!='\0';j++) {
            for (k=0;k<26;k++) {
                if (book[i].author[j]=='A'+k) {
                    time[k]+=1;
                    break;
                }
            }
        }
    }
    maxi=0;
    for(i=0;i<26;i++) {
        if (time[maxi]<time[i]) {
            maxi=i;
        }
    }
    printf("%c\n%d\n", 'A'+maxi, time[maxi]);
    for (i=0;i<n&&sign==0;i++) {
        for (j=0;book[i].author[j]!='\0';j++) {
            if (book[i].author[j]=='A'+maxi) {
                printf("\n%d", book[i].num);
                sign=1;
                break;
            }
        }
    }
    for (;i<n;i++) {
        for (j=0;book[i].author[j]!='\0';j++) {
            if (book[i].author[j]=='A'+maxi) {
                printf("\n%d", book[i].num);
                break;
            }
        }
    }
    return 0;
}


int main()
{
	struct tushu
	{
		int bianhao;
		char zuozhe[26];
	};
	int i,j,n,q=0;
	int count[26]={0};
	scanf("%d",&n);
	struct tushu *pp;
	pp=(struct tushu *)malloc(sizeof(tushu)*n);
	int *m;
	m=(int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
	{
		scanf("%d %s",&((pp+i)->bianhao),(pp+i)->zuozhe);
	}
	for(i=0;i<n;i++)
	{
		m[i]=strlen(pp[i].zuozhe);
		for(j=0;j<m[i];j++)
		{
			count[pp[i].zuozhe[j]-'A']++;
		}
	}
	int max=0;
	for(i=0;i<26;i++)
	{
		if(count[i]>max){max=count[i];q=i;}
	}
	printf("%c\n%d\n",'A'+q,max);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m[i];j++)
		{
			if(pp[i].zuozhe[j]==('A'+q))printf("%d\n",pp[i].bianhao);
		}
	}

	return 0;
}


struct SHU
{
	int bh;
	char bz[26];
};

int main()
{
	int m,i,j,l,k,p;
	int name[200]={0},max,shuhao[1000];
	struct SHU shu[1000];
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&shu[i].bh,shu[i].bz);
	}
	for(i=0;i<m;i++)
	{
		l=strlen(shu[i].bz);
		for(j=0;j<l;j++)
		{
			name[shu[i].bz[j]]++;
		}
	}
	max=name[0];
	for(i=0;i<200;i++)
	{
		if(name[i]>max)
		{
			max=name[i];
			k=i;
		}
	}
	p=0;
	for(i=0;i<m;i++)
	{
		for(j=0;j<26;j++)
		{
			if(shu[i].bz[j]==k)
			{
				shuhao[p]=shu[i].bh;
				p++;
			}
		}
	}
	printf("%c\n",k);
	printf("%d\n",max);
	for(i=0;i<p;i++)
	{
		printf("%d\n",shuhao[i]);
	}

	return 0;
}


struct student
{int num;
 char s[26];

}stu[999];

int main()
{   int m,a[26]={0},i,j,max,k,l=0;
    scanf("%d",&m);
    for(i=0;i<m;i++)
    scanf("%d%s",&stu[i].num,stu[i].s);
	for(i=0;i<26;i++)
	for(k=0;k<m;k++)
       for(j=0;j<strlen(stu[k].s);j++)
		   if(stu[k].s[j]=='A'+i)
			   a[i]++;

       max=a[0];
	for(i=1;i<26;i++)
		if(a[i]>max)
		{	max=a[i];l=i;}
		printf("%c\n",'A'+l);
		printf("%d\n",max);
	for(i=0;i<m;i++)
		for(j=0;j<strlen(stu[i].s);j++)
		   if(stu[i].s[j]=='A'+l)
		   {	printf("%d\n",stu[i].num);
		   break;}

	return 0;
}


void main()
{
int  n,len,i,j,k,max;
int c[26]={0};
char a[26],f,x;
struct book{ int num; char author[26];};
struct book b[1000];
scanf("%d",&n);
for (i=0;i<n;i++)
scanf("%d %s",&b[i].num,&b[i].author);
for(i=0;i<n;i++)
{
	strcpy(a,b[i].author);
len=strlen(a);
for(j=0;j<len;j++)
if('A'<=(x=a[j])&&(x=a[j])<='Z')
c[x-'A']++;
}
max=c[0];k=0;
for(i=0;i<26;i++)
{if(c[i]>max)
{max=c[i];
k=i;
}}
printf("%c\n%d\n",k+'A',max);
for(i=0;i<n;i++)
{
strcpy(a,b[i].author);
len=strlen(a);
for(j=0;j<len;j++)
if((f=a[j])==k+'A')
printf("%d\n",b[i].num);

}

}


struct st
{
	int a;
	char s[26];
	struct st *n;
}
;
struct st *creat(int m)
{
	int i;
	struct st *p1,*p2,*head;
	for(i=0;i<m;i++)
	{
		p1=(struct st *)malloc(len);
		if(i==0)head=p1;
		else p2->n=p1;
		scanf("%d %s",&p1->a,p1->s);
		p2=p1;
	}
	p1->n=NULL;
	return(head);
}
void main()
{
	int m;
	struct st *creat(int m);
	scanf("%d",&m);
	struct st *p,*q;
	p=creat(m);
	q=p;
	int i,j,k;
	int a[26]={0};
	for(i=0;i<m;i++)
	{
		for(j=0;j<(k=strlen(p->s));j++)a[p->s[j]-65]++;
		p=p->n;
	}
	p=q;
	int max=a[0];
	for(i=1;i<26;i++)
	{
		if(a[i]>max)max=a[i];
	}
	char c;
	for(i=0;i<26;i++)
	{
		if(a[i]==max)
		{
			c=i+65;
			printf("%c\n%d\n",c,a[i]);
			break;
		}
	}
	char cc;
	for(i=0;i<m;i++)
	{
		for(j=0;;j++)
		{
			cc=q->s[j];
			if(cc=='\0')break;
			if(c==cc)printf("%d\n",q->a);
		}
		q=q->n;
	}
}


struct book
{
	int no;
	char auth[26];
};
void main()
{
	struct book *head,*BK;
	int m,n,k,i,j,t,q,p,max;
	int a[26]={0};
	scanf("%d",&m);
	BK=(struct book*)malloc(m*LEN);
	head=BK;
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&BK->no,&BK->auth);
		n=strlen(BK->auth);
		for(j=0;j<n;j++)
		{
			k=BK->auth[j]-'A';
			a[k]=a[k]+1;
		}
		BK=BK+1;
	}
	max=a[0];
	t=0;
	for(i=1;i<26;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
			t=i;
		}
	}
	q=t+'A';
	printf("%c\n%d\n",q,max);
	BK=head;
	for(i=0;i<m;i++)
	{
		p=0;
		n=strlen(BK->auth);
		for(j=0;j<n;j++)
		{
			if(BK->auth[j]==q)
			{
				p=1;
				break;
			}
		}
		if(p==1)
		{
			printf("%d\n",BK->no);
		}
		BK=BK+1;
	}
}


int main()
{
	int k;
	cin>>k;
	int book;
	char writer[26];
	int counter[26]={0};
	int bookbelong[26][999]={0};
	int everynum[26]={0};
	int t=0;
    while(k--)
	{
		cin>>book>>writer;
		int str=strlen(writer);
	    for(int i=0;i<str;i++)

		{
			int flag=writer[i]-'A';
			counter[flag]++;
		    bookbelong[flag][everynum[flag]++]=book;
	}
	}
	int max=counter[0];
	int maxnum=0;
	for(int i=0;i<26;i++)
	{
		if(counter[i]>max)
	{
		maxnum=i;
		max=counter[i];
	}}
char writerbest;
writerbest='A'+maxnum;
cout<<writerbest<<endl<<everynum[maxnum]<<endl;
for(int i=0;i<everynum[maxnum];i++)
	cout<< bookbelong[maxnum][i]<<endl;

	return 0;
}


struct record
{
	int id;
};

struct YyxNode
{
	struct record m_rec;
	struct YyxNode *next;
};

struct YyxLink
{
	int n;
	struct YyxNode *head;
	struct YyxNode *tail;
};

struct YyxLink *CreateNewLink()
{
	struct YyxLink *newLn;
	struct YyxNode *newNd;
	if(((newLn=(struct YyxLink*)malloc(sizeof(struct YyxLink)))==NULL)
		||((newNd=(struct YyxNode*)malloc(sizeof(struct YyxNode)))==NULL)){
		printf("Error: memory out! (1)");
		exit(-1);
	}

	newLn->n = 0;
	newLn->head = newNd;
	newNd->next = NULL;
	newLn->tail = newNd;

	return newLn;
}

struct YyxLink *AddNode(struct YyxLink *ln, const struct record *rec)
{
	struct YyxNode *newNd;
	if((newNd=(struct YyxNode*)malloc(sizeof(struct YyxNode)))==NULL){
		printf("Error: memory out! (2)");
		exit(-1);
	}

	newNd->m_rec = *rec;
	newNd->next = NULL;

	ln->tail->next = newNd;
	ln->tail = newNd;
	ln->n ++;

	return ln;
}

struct YyxLink *ClearLink(struct YyxLink *ln)
{
	struct YyxNode *delNd, *nextNd;
	delNd = ln->head->next;
	for(; delNd!=NULL; delNd=nextNd){
		nextNd = delNd->next;
		free(delNd);
	}

	ln->n = 0;
	ln->head->next = NULL;

	return ln;
}

void FreeLink(struct YyxLink *ln)
{
	ClearLink(ln);
	free(ln->head);
	free(ln);
}

int main()
{
	struct YyxLink **total;
	int m;
	struct record rec;
	char author[27];
	int i;
	char *pch;
	struct YyxNode *nd;

	if((total=(struct YyxLink**)malloc(26*sizeof(struct YyxLink*)))==NULL){
		printf("Error: memory out! (3)\n");
		exit(-1);
	}
	for(i=0; i<26; i++){
		total[i] = CreateNewLink();
	}

	scanf("%d", &m);
	for(; m>0; m--){
		scanf("%d %s", &rec.id, author);
		pch = author;
		for(; *pch!='\0'; pch++){
			AddNode(total[*pch-'A'], &rec);
		}
	}

	m = 0;
	for(i=1; i<26; i++){
		if(total[m]->n<total[i]->n)
			m = i;
	}
	printf("%c\n%d\n", m+'A', total[m]->n);
	nd = total[m]->head->next;
	for(; nd!=NULL; nd=nd->next){
		printf("%d\n", nd->m_rec);
	}

	return 0;
}


void main()
{
	struct book
	{
		int a;
		char b[20];
	}book[999];
	int n,i,k,max,m,j,p;
	int c[999]={0};
	char str1[20],str2[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %s",&book[i].a,&book[i].b);
		m=strlen(book[i].b);
        strcpy(str1,book[i].b);
		for(j=0;j<m;j++)
		c[str1[j]]=	c[str1[j]]+1;
	}
	max=0;
	for(p=65;p<91;p++)
	{
		if(c[p]>max)
		{max=c[p];
		k=p;}
	}
printf("%c\n",k);
printf("%d\n",max);
for(i=0;i<n;i++)
{
	strcpy(str2,book[i].b);
		m=strlen(book[i].b);
		for(j=0;j<m;j++)
		{if(str2[j]==k)
		printf("%d\n",book[i].a);}
}

}


struct shu
{
	int bianhao;
	char name[26];
}shu[999];

int main ()
{
	int m;
	scanf("%d",&m);
	int i,j,k;
	int jishu[26]={0};
	int beiyong[26];
	for (i=0;i<m;i++)
		scanf("%d %s",&shu[i].bianhao,shu[i].name);
    for (i=0;i<26;i++)
	{
		for (j=0;j<m;j++)
		{
			for (k=0;k<26;k++)
			{
				if (shu[j].name[k]==i+'A')
					jishu[i]++;
			}
		}
	}
	for (i=0;i<26;i++)
		beiyong[i]=jishu[i];
	int max=0;
	for (i=0;i<26;i++)
	{
		if (beiyong[i]>max)
			max=beiyong[i];
	}
	int t;
	for (i=0;i<26;i++)
	{
		if (jishu[i]==max)
			t=i;
	}
	printf("%c\n",t+'A');
	printf("%d\n",max);
	for (i=0;i<m;i++)
	{
		for (j=0;j<26;j++)
		{
			if (shu[i].name[j]==t+'A')
				printf("%d\n",shu[i].bianhao);
		}
	}
}


struct book
{
	int num;
	char name[100];
	struct book *next;
};

struct book *creat(int n)
{
	int k=1;
	struct book *head,*p1,*p2,*p;
	p1=(struct book *)malloc(sizeof(struct book));
	head=p1;p2=p1;p=p1;
	scanf("%d %s",&p1->num,p1->name);
	p1->next=NULL;
	do
	{
		p1=(struct book *)malloc(sizeof(struct book));
		scanf("%d %s",&p1->num,p1->name);
		p2->next=p1;
		p2=p1;
		p1->next=NULL;
		k++;
	}while(k<n);
	return head;
}

int main(void)
{
	struct book *head,*p;
	char *q;
	int *s;
	int n,i,j,max=0;
	s=(int *)malloc(26*sizeof(int));
	for(i=0;i<26;i++)
		*(s+i)=0;
	scanf("%d",&n);
	head=creat(n);
	p=head;
	while(p)
	{
		q=p->name;
		while(*q!='\0')
		{   *(s+*(q)-'A')+=1;q++;}
		p=p->next;
	}
	max=0;
	for(i=0;i<26;i++)
	    if(*(s+i)>max)
			max=*(s+i);
	for(i=0;i<26;i++)
	    if(*(s+i)==max) break;
	printf("%c\n%d\n",'A'+i,max);
	p=head;
	while(p)
	{
		q=p->name;
		if(strchr(q,'A'+i)!=NULL)
			printf("%d\n",p->num);
		p=p->next;
	}
}


int main()
{
	int n, i;
	scanf("%d", &n);
	struct
	{
		int name;
		char author[26];
	}
	book[999];

	for(i = 0; i < n; i++)
	{
		scanf("%d%s", &book[i].name, book[i].author);
	}

	char t, tmax;
	int max = 0, j, k;
	for(t = 'A'; t <= 'Z'; t++)
	{
		k = 0;
		for(i = 0; i < n; i++)
		{
			for(j = 0; j < strlen(book[i].author); j++)
			{
				if(book[i].author[j] == t)
				{
					k++;
				}
			}
		}
		if(k > max)
		{
			max = k;
			tmax = t;
		}
	}
	printf("%c\n%d\n", tmax, max);
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < strlen(book[i].author); j++)
		{
			if(book[i].author[j] == tmax)
			{
					printf("%d\n", book[i].name);
					break;
			}
		}
	}
	return 0;
}


void main()
{
int n,i,j,max=0,seq=0;
int a[26]={0};

scanf("%d",&n);
struct book
{
int num;
char str[26];
}book[999];

for(i=0;i<n;i++)
scanf("%d %s",&book[i].num,&book[i].str);

for(i=0;i<n;i++)
{
	for(j=0;j<26;j++)
	a[(book[i].str[j]-65)]++;
}

for(i=0;i<26;i++)
	if (a[i]>max) {max=a[i];seq=i;}

printf("%c\n",seq+65);
printf("%d\n",max);

for(i=0;i<n;i++)
{
for(j=0;j<26;j++)
if (book[i].str[j]==seq+65) {printf("%d\n",book[i].num); break;}
}

}


int main()
{
	int m, book[1002], i, cnt[26] = {0}, l, j, n = 0;
	char name[1002][27], a, max ;
	cin >> m;
	for (i = 0; i < m; i++)
	{
		cin >> book[i];
		cin >> name[i];
		l = strlen(name[i]);
		for (j = 0; j < l; j++)
		{
			a = name[i][j];
			cnt[a - 'A']++;
		}
	}
	for (i = 0; i < 26; i++)
		{
			if (cnt[i] > n)
			{
				n = cnt[i];
				max = i + 'A';
			}
		}
		cout << max << endl;
		cout << n << endl;
		for (i = 0; i < m; i++)
		{
			l = strlen (name[i]);
			for (j = 0; j < l; j++)
			{
				if (name[i][j] == max)
				{
					cout << book[i] << endl;
					break;
				}
			}
		}
	return 0;
}


struct b
{
	int na;
	char au[20];
}book[1000];
int main()
{
	int m,i,len[1000],num[128]={0},j,max,p=0;
	char maxi;
	int boo[1000];
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%s",&book[i].na,book[i].au);
		len[i]=strlen(book[i].au);
		for(j=0;j<len[i];j++)
			num[book[i].au[j]]++;
	}
	maxi='A';
	max=-1;
	for(j='A';j<='Z';j++)
	{
		if(num[j]>max)
		{
			max=num[j];
			maxi=j;
		}
	}
	printf("%c\n",maxi);
	printf("%d\n",max);
	for(i=0;i<m&&p<max;i++)
	{
		for(j=0;j<len[i];j++)
		{
			if(book[i].au[j]==maxi)
			{
				printf("%d\n",book[i].na);
				p++;
				break;
			}
		}
	}
	return 0;
}


struct book
	{
		char id[11];
		char name[30];
	};
struct au
{
	int num;
	char id[1000][11];
};
void main()
{
	struct book b;
	struct au a[26];
	int n,i,j=0,k;
	char c;
	for(i=0;i<26;i++)
		a[i].num=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%s",b.id,b.name);
		while(b.name[j]!='\0')
		{
			k=b.name[j]-'A';
			strcpy(a[k].id[a[k].num],b.id);
			a[k].num++;
			j++;
		}
		j=0;
	}
	k=0;
	j=0;
	for(i=0;i<26;i++)
	{
		j=(a[i].num>k)? i:j;
		k=(a[i].num>k)? a[i].num:k;
	}
	printf("%c\n",'A'+j);
	printf("%d\n",k);
	for(i=0;i<k;i++)
		printf("%s\n",a[j].id[i]);
}


struct
{
	int num;
   	char name[27];
}book[999];
struct
{
	int cishu;
}ren[26];
int main()
{
	int n,zimu,a,b,i,j;
	int sz[26];
	char m;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d %s",&book[i].num,book[i].name);
	}
    for(i=0;i<n;i++)
	{
		for(j=0;book[i].name[j]!='\0';j++)
		{
			   zimu=book[i].name[j]-65;
			   ren[zimu].cishu++;
		}
	}
	a=0;
	b=ren[0].cishu;
    for(i=1;i<26;i++)
	{
       if(ren[i].cishu>b)
	   {
		   a=i;
		   b=ren[i].cishu;
	   }

	}
    m=a+65;
	printf("%c\n",m);
	printf("%d\n",b);
    for(i=0;i<n;i++)
	{
		for(j=0;j<26;j++)
		{
			if(book[i].name[j]==m)
			{
			   printf("%d\n",book[i].num);
			}
		}
	}

	return 0;
}


main()
{
      int n,i,j,max=0,maxp;
      scanf("%d",&n);
      int a[n];
      int person[26]={0};
      char writer[n][26];
      for (i=0;i<n;i++)
      {
          scanf("%d %s",&a[i],writer[i]);
          for (j=0;j<strlen(writer[i]);j++)
          {
              person[writer[i][j]-'A']++;
          }
      }
      for (i=0;i<26;i++)
      {
          if (max<person[i])
          {
                            max=person[i];
                            maxp=i;
          }
      }
      printf("%c\n%d\n",maxp+'A',max);
      for(i=0;i<n;i++)
                      for(j=0;j<strlen(writer[i]);j++)
                      {
                                                      if (writer[i][j]=='A'+maxp)
                                                      printf("%d\n",a[i]);
                      }
}


int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;
int max = 0;
char maxn;
struct book
{
	int id;
	char author[28];
}*bb;
void find ( int ii );

int main()
{
	int n;
	scanf("%d",&n);
	int ii;
	bb = ( struct book * ) malloc ( sizeof ( struct book ) * n );
	for ( ii = 0; ii < n ; ii++ )
	{
		scanf("%d %s",&bb[ii].id,bb[ii].author);
	}
	for ( ii = 0 ; ii < n ; ii++ )
	{
		find (ii);
	}
	printf("%c\n",maxn);
	printf("%d\n",max);

	int jj;
	for ( ii = 0 ; ii < n ; ii++ )
	{
		for ( jj = 0 ; bb[ii].author[jj] != '\0' ; jj++)
		{
			if ( bb[ii].author[jj] == maxn )
			{
				printf("%d\n",bb[ii].id);
			}
		}
	}
	free(bb);
	return 0;
}

void find ( int ii )
{
	int aa = 0;
	for ( aa = 0 ; bb[ii].author[aa] != '\0' ; aa++ )
	{
		switch(bb[ii].author[aa])
		{
case 'A':{a++;if ( a > max ) max = a,maxn = 'A' ; break;}
case 'B':{b++;if ( b > max ) max = b,maxn = 'B' ; break;}
case 'C':{c++;if ( c > max ) max = c,maxn = 'C' ; break;}
case 'D':{d++;if ( d > max ) max = d,maxn = 'D' ; break;}
case 'E':{e++;if ( e > max ) max = e,maxn = 'E' ; break;}
case 'F':{f++;if ( f > max ) max = f,maxn = 'F' ; break;}
case 'G':{g++;if ( g > max ) max = g,maxn = 'G' ; break;}
case 'H':{h++;if ( h > max ) max = h,maxn = 'H' ; break;}
case 'I':{i++;if ( i > max ) max = i,maxn = 'I' ; break;}
case 'J':{j++;if ( j > max ) max = j,maxn = 'J' ; break;}
case 'K':{k++;if ( k > max ) max = k,maxn = 'K' ; break;}
case 'L':{l++;if ( l > max ) max = l,maxn = 'L' ; break;}
case 'M':{m++;if ( m > max ) max = m,maxn = 'M' ; break;}
case 'N':{n++;if ( n > max ) max = n,maxn = 'N' ; break;}
case 'O':{o++;if ( o > max ) max = o,maxn = 'O' ; break;}
case 'P':{p++;if ( p > max ) max = p,maxn = 'P' ; break;}
case 'Q':{q++;if ( q > max ) max = q,maxn = 'Q' ; break;}
case 'R':{r++;if ( r > max ) max = r,maxn = 'R' ; break;}
case 'S':{s++;if ( s > max ) max = s,maxn = 'S' ; break;}
case 'T':{t++;if ( t > max ) max = t,maxn = 'T' ; break;}
case 'U':{u++;if ( u > max ) max = u,maxn = 'U' ; break;}
case 'V':{v++;if ( v > max ) max = v,maxn = 'V' ; break;}
case 'W':{w++;if ( w > max ) max = w,maxn = 'W' ; break;}
case 'X':{x++;if ( x > max ) max = x,maxn = 'X' ; break;}
case 'Y':{y++;if ( y > max ) max = y,maxn = 'Y' ; break;}
case 'Z':{z++;if ( z > max ) max = z,maxn = 'Z' ; break;}
		}
	}
}


struct book{
	int num;
	char s[27];
};

struct author{
	int num;
	int bn[1000];
};

int main()
{
	int m,i,j,l,max=0;

	char c;

	struct book bk[1000];
	struct author au['Z'+1],t;

	scanf("%d",&m);
  for(j=0;j<'Z'+1;j++)
		au[j].num=0;
	for(i=0;i<m;i++)
	{

		scanf("%d %s",&bk[i].num,bk[i].s);

		l=strlen(bk[i].s);

		for(j=0;j<l;j++)
		au[bk[i].s[j]].bn[au[bk[i].s[j]].num++]=bk[i].num;
	}

	for(j=0;j<'Z'+1;j++)
		if(au[j].num>max)
		{	t=au[j];
		c=j;
		max=au[j].num;}

	printf("%c\n",c);
	printf("%d\n",t.num);

	for(i=0;i<t.num;i++)
		printf("%d\n",t.bn[i]);

	return 0;
}


struct shu
{
	int num;
	char a[26];
	struct shu*next;
};
int main()
{
	char ma='A';
	struct shu *p1,*p2;
	struct shu*head,*p;
	int cnt[128]={0};
	int i,j,n,m;
	scanf("%d",&n);
	p1=p2=(struct shu*)malloc(l);
	scanf("%d%s",&p1->num,p1->a);
	m=strlen(p1->a);
	for(j=0;j<m;j++){
		if(++cnt[p1->a[j]]>cnt[ma])
			ma=p1->a[j];
	}
	head=NULL;
	for(i=1;i<n;i++){
		if(i==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct shu*)malloc(l);
		scanf("%d%s",&p1->num,p1->a);
		m=strlen(p1->a);
		for(j=0;j<m;j++){
			if(++cnt[p1->a[j]]>cnt[ma])
				ma=p1->a[j];
		}
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;
	p=head;
	printf("%c\n%d\n",ma,cnt[ma]);
	while(p!=NULL){
		m=strlen(p->a);
		for(i=0;i<m;i++){
			if(p->a[i]==ma){
			printf("%d\n",p->num);
			break;
			}
		}
		p=p->next;
	}
	return 0;
}


struct BOOK
{
	int num;
	char name[26];
	int name_num[26];
}book[999];

void main()
{
	int n;                                  //????//
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%d%s",&book[i].num,&book[i].name);    //??????????????????i??j????????????//
	}

	int count[26]={0};
	int k;
	for(i=0;i<n;i++){
		int len;
		len=strlen(book[i].name);
		for(k=0;k<len;k++){
			book[i].name_num[k]=(int)book[i].name[k];
		}
	}

	int j;
	int y;
	for(i=0;i<n;i++){
		int len_1;
		len_1=strlen(book[i].name);
		for(j=65;j<=90;j++){
			for(y=0;y<len_1;y++){
				if(book[i].name_num[y]==j){
					count[j-65]++;
				}
			}
		}
	}

	int w;
	int max=count[0];
	int t=0;
	for(w=0;w<26;w++){
		if(count[w]>max){
			max=count[w];
			t=w;
		}
	}
	printf("%c\n%d\n",t+65,max);

	int x;
	int total=0;
	for(i=0;i<n;i++){
		int length;
		length=strlen(book[i].name);
		for(x=0;x<length;x++){
			if(book[i].name_num[x]==t+65){
				printf("%d\n",book[i].num);
			}
		}
	}

}


struct author{
int sumbook;
int id[999];
}a[26];

int main(){
    int n,i,j,bookid=0,pos=0,maxbook=0,maxid=0;
    char booka[26];
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d%s",&bookid,booka);
        for(j=0;j<strlen(booka);++j){
            pos=booka[j]-'A';
            a[pos].id[a[pos].sumbook]=bookid;
            a[pos].sumbook++;
            if(maxbook<a[pos].sumbook){
               maxid=pos;
               maxbook=a[pos].sumbook;
            }
        }
    }
    printf("%c\n%d\n",maxid+'A',maxbook);
    for(i=0;i<a[maxid].sumbook;i++)
     printf("%d\n",a[maxid].id[i]);
}


struct author {
	char id;
	int count;
	int books[1000];
};

int cmp(const void *a, const void *b) {
	const struct author *pa = (const struct author *) a;
	const struct author *pb = (const struct author *) b;
	return pb->count - pa->count;
}

int main() {
	int i, j, num, id, len, idx;
	struct author authors[26]; // 'A' -- 'Z'
	char c;
	char buffer[26];

	for (i = 0; i < 26; ++i) {
		authors[i].id = 'A' + i;
		authors[i].count = 0;
	}

	scanf("%d", &num);
	for (i = 0; i < num; ++i) {
		scanf("%d %s", &id, buffer);
		len = strlen(buffer);
		for (j = 0; j < len; ++j) {
			idx = buffer[j] - 'A';
			authors[idx].books[authors[idx].count] = id;
			authors[idx].count++;
		}
	}

	qsort(authors, 26, sizeof(struct author), cmp);

	printf("%c\n", authors[0].id);
	printf("%d\n", authors[0].count);
	for (i = 0; i < authors[0].count; ++i)
		printf("%d\n", authors[0].books[i]);
}


int main()
{
	struct bookst
	{
		int Num;
		char name[26];
	};
	struct bookst *book;
	int cnt[26], num, i, j, max=0, max_idx=0;
	for(i=0;i<26;i++)
		cnt[i]=0;
	scanf("%d",&num);
	book=(struct bookst *)malloc(num*sizeof(struct bookst));
	for(i=0;i<num;i++)
	{
		scanf("%d%s",&book[i].Num,book[i].name);
		for(j=0;book[i].name[j]!=0;j++)
		{
			cnt[book[i].name[j]-'A']++;
		}
	}
	for(i=0;i<26;i++)
	{
		if(cnt[i]>max)
		{
			max=cnt[i];
			max_idx=i;
		}
	}
	printf("%c\n%d\n",'A'+max_idx,max);
	for(i=0;i<num;i++)
	{
		for(j=0;book[i].name[j]!=0;j++)
		{
			if(book[i].name[j]=='A'+max_idx)
				printf("%d\n",book[i].Num);
		}
	}
	return 0;
}


struct list
{
       int book;
       char name[30];
};

int main(int argc, char *argv[])
{
  int n,i,j;
  scanf("%d",&n);
  int a[26];
  struct list shelf[n];
  for (i=0;i<=25;i++)
      a[i]=0;
  for (i=0;i<=n-1;i++)
  {
      scanf("%d%s",&shelf[i].book,shelf[i].name);
      for (j=0;j<=strlen(shelf[i].name)-1;j++)
          a[shelf[i].name[j]-'A']++;
  }
  int max,flag=0,add=0,temp=0;
  max=a[0];
  for (i=0;i<=25;i++)
  {
      if (max<a[i])
      {max=a[i];flag=i;}
  }
  printf("%c\n",flag+'A');
  printf("%d\n",max);
  for (i=0;i<=n-1;i++)
  {
      for (j=0;j<=strlen(shelf[i].name)-1;j++)
      {
          if (shelf[i].name[j]==flag+'A')
          add++;
      }
  }
  for (i=0;i<=n-1;i++)
  {
      for (j=0;j<=strlen(shelf[i].name)-1;j++)
      {
          if (shelf[i].name[j]==flag+'A')
          {printf("%d",shelf[i].book);
          temp++;
          (temp<add)?printf("\n"):printf("");
          break;
          }
      }
  }
  return 0;
}


struct shu
{
	int num;
	char author_name[27];
};

int main()
{
	int ere[26];
	int m,i,max=0,key;
	for(i=0;i<26;i++)
	{
		ere[i]=0;
	}
	char *a;
	struct shu book[999];
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&book[i].num);
		scanf("%s",book[i].author_name);
	}
	for(i=0;i<m;i++)
	{
		a=book[i].author_name;
		while(*a!='\0')
		{
			ere[(*a)-'A']++;
			a++;
		}
	}
	for(i=0;i<26;i++)
	{
		if(ere[i]>=max)
		{
			max=ere[i];
			key=i;
		}
	}
	printf("%c\n",(key+'A'));
	printf("%d\n",ere[key]);
	for(i=0;i<m;i++)
	{
		a=book[i].author_name;
		while(*a!='\0')
		{
			if((key+'A')==*a)
			{
				printf("%d\n",book[i].num);
				break;
			}
			a++;
		}
	}
	return 0;
}


int main()
{
	char author[27];
	int i,j,n,no,ab[26][1000]={0},an[26]={0},ma=0,na,am;
	cin>>n;
	for(;n>0;n--){
		cin>>no>>author;
		for(i=0;i<27;i++)
			if(author[i]!='\0')ab[author[i]-'A'][an[author[i]-'A']]=no,an[author[i]-'A']++;
			else break;}
	for(i=0;i<26;i++)
	{
		na=0;
		for(j=0;j<999;j++)
			if(ab[i][j]!=0)na++;
			else break;
		if(na>ma)
			ma=na,am=i;
	}
	cout<<(char)('A'+am)<<endl<<ma<<endl;
	for(i=0;i<1000;i++)
		if(ab[am][i]!=0)cout<<ab[am][i]<<endl;
		else break;
	return 0;
}


struct book
{ int n;
  struct book *next;
};
struct au
{
	char n;
	int s;
	struct book *p;
};
void main()
{
	int i,j,k,l,m,n,*p,a[100][1100]={0},max=0,b[100]={0};
	char s[30];
	scanf("%d",&n);
	for(l=1;l<=n;l++)
	{
		scanf("%d",&j);
		scanf("%s",s);
		for(i=0;s[i]!='\0';i++)
		{
			b[s[i]]++;
			a[s[i]][b[s[i]]]=j;
		if(b[s[i]]>b[max]) max=s[i];
		}
	}
	printf("%c\n",(char)max);
	printf("%d\n",b[max]);
	for(i=1;i<=b[max];i++)
		printf("%d\n",a[max][i]);

}


struct book{
       int num;
       char aut[100];
       }b[200000];
int count[1000]={0};

int main()
{
    int n,max=0,maxnum,i,j,f;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
                      scanf("%d %s", &b[i].num, b[i].aut);
                      for(j=0;j<strlen(b[i].aut);j++){count[b[i].aut[j]]++;}
                      }
    for(i='A';i<='Z';i++){
                         if(count[i]>max){
                                          max=count[i];
                                          maxnum=i;
                                          }
                         }
    printf("%c\n%d\n", maxnum, max);
    for(i=1;i<=n;i++){
                      f=0;
                      for(j=0;j<strlen(b[i].aut);j++){
                                                      if(b[i].aut[j]==maxnum){f=1;}
                                                      }
                      if(f==1){printf("%d\n", b[i].num);}
                      }

    return 0;
}


struct book
{
	int num;
	char a[26];
	struct book *next;
};
void main()
{
	struct book *head,*p,*s;
	head=(struct book *)malloc(sizeof(struct book));
	head->next=NULL;
	int n,i,j,c[26]={0},max,maxj;
	char b[26];
	for(j=0;j<26;j++)
		b[j]=65+j;
	scanf("%d",&n);
	p=head;
	for(i=0;i<n;i++)
	{
		s=(struct book *)malloc(sizeof(struct book));
		scanf("%d %s",&s->num,s->a);
		s->next=NULL;
		p->next=s;
		p=s;
	}
	for(p=head->next;p!=NULL;p=p->next)
	{
		for(i=0;p->a[i]!='\0';i++)
			for(j=0;j<26;j++)
				if(p->a[i]==b[j])
					c[j]++;
	}
//	for(j=0;j<26;j++)
  //      printf("%c %d\n",b[j],c[j]);
	max=c[0];
	maxj=0;
	for(j=1;j<26;j++)
		if(c[j]>max)
		{
			max=c[j];
			maxj=j;
		}
	printf("%c\n",b[maxj]);
	printf("%d\n",c[maxj]);
	for(p=head->next;p!=NULL;p=p->next)
		for(i=0;p->a[i]!='\0';i++)
			if(p->a[i]==b[maxj])
				printf("%d\n",p->num);
}


void main()
{
	struct book
	{
		int bianhao;
		char zuozhe[100];
	}a[1000];
	int i,j,n,l,max;
	int b[26]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d %s",&a[i].bianhao,a[i].zuozhe);
	for(i=0;i<n;i++)
	  for(j=0;a[i].zuozhe[j]!='\0';j++)
		b[a[i].zuozhe[j]-65]++;
	max=b[0];
	l=0;
	for(i=1;i<=25;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
			l=i;
		}
	}
	printf("%c\n",l+65);
	printf("%d\n",max);
	for(i=0;i<n;i++)
		for(j=0;a[i].zuozhe[j]!='\0';j++)
			if(a[i].zuozhe[j]==(l+65))
			{
				printf("%d\n",a[i].bianhao);
			    break;
			}
}


int main()
{
	int x[26]={0};
	char c;
	struct books
	{
		int number;
		char name[27];
	};
	struct books book[1000];
	int n,i,j,t,max=0;
	struct books *p;
	scanf("%d",&n);
	for(p=book;p<book+n;p++)
		scanf("%d%s",&p->number,p->name);
	for(p=book;p<book+n;p++)
		for(j=0;j<26;j++)
			for(i=65;i<=90;i++)
			    if(p->name[j]==i)
					x[i-65]++;
	for(i=0;i<26;i++)
		if(x[i]>max)
			max=x[i];
	for(i=0;i<26;i++)
		if(x[i]==max)
			break;
	c=i+65;
	printf("%c\n%d\n",c,max);
	for(i=0;i<n;i++)
		for(j=0;j<26;j++)
			if(book[i].name[j]==c)
			{
				printf("%d\n",book[i].number);
				break;
			}

	return 0;
}


struct books
{
	int num;
	char name[100];
	struct books *next;
};
struct books * create(int n)
{
	struct books *head,*p1,*p2;
	p1=(struct books*)malloc(Len);
	scanf("%d %s",&p1->num,p1->name);
	p1->next=NULL;
	head=p1;
	p2=p1;
	while(--n)
	{
		p1=(struct books*)malloc(Len);
		scanf("%d %s",&p1->num,p1->name);
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	return head;
}
void main()
{
	int n,i,max,k;
    char *p;
	int num[26]={0};
	char name[26]={'A','B','C','D','E','F','G','H','I','J','K','L',
		'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	struct books *p1,*head;
	scanf("%d",&n);
    head=create(n);
	p1=head;
	for(i=0;i<26;i++)
	{
		p1=head;
		p=p1->name;
		do
		{

			if(*p==name[i])
			{
				num[i]++;
				p1=p1->next;
				p=p1->name;
			}
			else
			{
				if(*p=='\0')
				{
					p1=p1->next;
					p=p1->name;
				}
				else
				{
					p++;
				}
			}
		}while(p1!=NULL);
	}
	max=num[0];
	for(i=0;i<26;i++)
	{
		if(num[i]>=max)
		{
			k=i;
			max=num[i];//???????num[i]??max??????max????????????25
		}
	}
	printf("%c\n",name[k]);
	printf("%d\n",num[k]);
	p1=head;
	p=p1->name;
	while(p1!=NULL)
	{

		if(*p==name[k])
		{
			printf("%d\n",p1->num);
			p1=p1->next;
			p=p1->name;
		}
		else
		{
			if(*p=='\0')
			{
				p1=p1->next;
				p=p1->name;
			}
			else
			{
				p++;
			}
		}
	}
}


int main()
{
	int num[999] , count[27] = {0} , len[999];
	int m , i , j , max = 0 , per;
	cin >> m;
	char ch[999][26] , person;
	for (i = 1 ; i <= m ; i++)
	{
		cin >> num[i] >> ch[i];
		len[i] = strlen (ch[i]);
		for (j = 0 ; j <= len[i] - 1 ; j++)
		{
			count[ch[i][j] - 64]++;
		}
	}
	for (i = 1 ; i <= 26 ; i++)
	{
		if (count[i] > max)
		{
			max = count[i];
			per = i;
		}
	}
	person = per + 64;
	cout << person << endl;
	cout << count[per] << endl;
    for (i = 1 ; i <= m ; i++)
	{
		for (j = 0 ; j <= len[i] - 1 ; j++)
		{
			if (ch[i][j] == person)
			{
				cout << num[i] << endl;
				break;
			}
		}
	}
	return 0;
}


typedef char q[30];
void init(int a[],int f[],q *p[lll],int m)
{
	int i;

char e[432];
char *pp;
int r;
	for(i=1;i<=m;i++)
	{
		p[i]=(q *)malloc(sizeof(q));

		scanf("%d%s",&f[i],p[i]);
		getchar();
		pp=*p[i];
		while (*pp!='\0')
		{a[*pp]++;
		 pp++;
	    }

	}

}
char pro(int a[])
{
	char c,max,g;
	max=-333;
	for (c='A';c<='Z';c++)

	if (a[c]>max) {max=a[c];g=c;}
	return g;
}
void print(int f[],q *p[lll],int m,char c)
{
	int i;
		for (i=1;i<=m;i++)
			if (strchr(*p[i],c)!=NULL) printf("%d\n",f[i]);
}
int main()
{
	int m,k;
	int a[343]={0};
		int f[lll];
		q *p[lll];
		char max;
	//freopen("tt.in","r",stdin);
	//freopen("tt.out","w",stdout);
	scanf("%d",&m);

	init(a,f,p,m);
	max=pro(a);
	printf("%c\n%d\n",max,a[max]);

	print(f,p,m,max);

}


struct book
{
	int num;
	char name[27];
}book[1000];

int main(int argc, char* argv[])
{
	int m,i,j,a[27],len,max=0,number;
	char p;
	for(i=1;i<=26;i++){
		a[i]=0;
	}
	scanf("%d",&m);
	for(i=1;i<=m;i++){
		scanf("%d %s",&book[i].num,&book[i].name);
		len=strlen(book[i].name);
		for(j=0;j<=len-1;j++){
			p=book[i].name[j];
			a[p-64]+=1;
		}
	}
	for(i=1;i<=26;i++){
		if(a[i]>max){
			max=a[i];
			number=i;
		}
	}
	printf("%c\n%d\n",number+64,a[number]);
	for(i=1;i<=m;i++){
		len=strlen(book[i].name);
		for(j=0;j<=len-1;j++){
			if(book[i].name[j]==number+64){
				printf("%d\n",book[i].num);
			}
		}
	}

	return 0;
}


char f(int y);

int main()
{
	int m,i,j,number[1000],auther[26],total=0;
	char name[1000][27];
    scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %s",&number[i],name[i]);
		int n;
		n=strlen(name[i]);
		for(j=0;j<n;j++){
			switch(name[i][j]){
			case'A':auther[0]++;break;
			case'B':auther[1]++;break;
			case'C':auther[2]++;break;
            case'D':auther[3]++;break;
			case'E':auther[4]++;break;
			case'F':auther[5]++;break;
			case'G':auther[6]++;break;
			case'H':auther[7]++;break;
			case'I':auther[8]++;break;
			case'J':auther[9]++;break;
			case'K':auther[10]++;break;
			case'L':auther[11]++;break;
			case'M':auther[12]++;break;
			case'N':auther[13]++;break;
			case'O':auther[14]++;break;
			case'P':auther[15]++;break;
			case'Q':auther[16]++;break;
			case'R':auther[17]++;break;
			case'S':auther[18]++;break;
			case'T':auther[19]++;break;
			case'U':auther[20]++;break;
			case'V':auther[21]++;break;
			case'W':auther[22]++;break;
			case'X':auther[23]++;break;
			case'Y':auther[24]++;break;
            case'Z':auther[25]++;break;
			}
		}
	}
	int max=auther[0],k,t=0;
	for(k=1;k<26;k++){
		if(auther[k]>max){
			max=auther[k];
		    t=k;
		}
	}
	printf("%c\n",f(t));
	for(i=0;i<m;i++){
        int q;
		q=strlen(name[i]);
		for(j=0;j<q;j++){
			if(name[i][j]==f(t))
				total++;
		}
	}
	printf("%d\n",total);
	for(i=0;i<m;i++){
        int p;
		p=strlen(name[i]);
		for(j=0;j<p;j++){
			if(name[i][j]==f(t))
				printf("%d\n",number[i]);
		}
	}
	return 0;
}

	char f(int y){
			char x;
			switch(y){
			case 0:x='A';break;
			case 1:x='B';break;
			case 2:x='C';break;
			case 3:x='D';break;
			case 4:x='E';break;
			case 5:x='F';break;
			case 6:x='G';break;
            case 7:x='H';break;
			case 8:x='I';break;
			case 9:x='J';break;
			case 10:x='K';break;
			case 11:x='L';break;
			case 12:x='M';break;
			case 13:x='N';break;
			case 14:x='O';break;
			case 15:x='P';break;
			case 16:x='Q';break;
			case 17:x='R';break;
            case 18:x='S';break;
			case 19:x='T';break;
			case 20:x='U';break;
			case 21:x='V';break;
			case 22:x='W';break;
			case 23:x='X';break;
			case 24:x='Y';break;
			case 25:x='Z';break;
			}
			return x;
		}


int main()
{
    int n;
    int i, j;
    int book_number[26];
    int max = 0;
    int max_n;
    int author_len;

    struct data
    {
           int number;
           char author[27];
    };

    scanf("%d", &n);

    struct data *input = (struct data*) malloc(sizeof(struct data) * n);

    for(j = 0; j <= 25; j++)
          book_number[j] = 0;

    for(i = 0; i <= n - 1; i++)
    {
          scanf("%d %s", &input[i].number, input[i].author);
          author_len = strlen(input[i].author);

          for(j = 0; j <= author_len - 1; j++)
                book_number[input[i].author[j] - 'A']++;

    }

    for(j = 0; j <= 25; j++)
    {
          if(book_number[j] > max)
          {
                            max = book_number[j];
                            max_n = j;
          }
    }

    printf("%c\n%d\n", max_n + 'A', max);

    for(i = 0; i <= n - 1; i++)
    {
          author_len = strlen(input[i].author);

          for(j = 0; j <= author_len - 1; j++)
          {
                if(input[i].author[j] == max_n + 'A')
                {
                                      printf("%d\n", input[i].number);
                                      break;
                }
          }
    }

    free(input);

    return 0;
}


int main(int argc, char* argv[])
{
	int m,i,j=0,zhe[26],t=0,x,name;
	for(i=0;i<26;i++)
	{
		zhe[i]=0;
	}
	char s[26];
	scanf("%d",&m);
	struct
	{
		int num;
		char s[26];
	}shu[1000];
	for(i=0;i<m;i++)
	{
		scanf("%d%s",&shu[i].num,shu[i].s);
	}
for(i=0;i<m;i++)
{
    for(j=0;shu[i].s[j]!=0;j++)
	{
    	switch(shu[i].s[j])
		{
        	case 'A':zhe[0]++;break;
            case 'B':zhe[1]++;break;
        	case 'C':zhe[2]++;break;
	        case 'D':zhe[3]++;break;
	case 'E':zhe[4]++;break;
	case 'F':zhe[5]++;break;
	case 'G':zhe[6]++;break;
	case 'H':zhe[7]++;break;
	case 'I':zhe[8]++;break;
	case 'J':zhe[9]++;break;
	case 'K':zhe[10]++;break;
	case 'L':zhe[11]++;break;
	case 'M':zhe[12]++;break;
	case 'N':zhe[13]++;break;
	case 'O':zhe[14]++;break;
	case 'P':zhe[15]++;break;
	case 'Q':zhe[16]++;break;
	case 'R':zhe[17]++;break;
	case 'S':zhe[18]++;break;
	case 'T':zhe[19]++;break;
	case 'U':zhe[20]++;break;
	case 'V':zhe[21]++;break;
	case 'W':zhe[22]++;break;
	case 'X':zhe[23]++;break;
	case 'Y':zhe[24]++;break;
	case 'Z':zhe[25]++;break;
		}
	}
	}
	    for(j=0;j<26;j++)
		{
			if(zhe[j]>t)
			{
				t=zhe[j];
			    x=j;
			}
		}
			name='A'+x;
			printf("%c\n",name);
		printf("%d\n",t);
		for(i=0;i<m;i++)
		{
			for(j=0;j<26;j++)
			{
			if(shu[i].s[j]==name)
				printf("%d\n",shu[i].num);
			}
		}

	return 0;
}


int main()
{
	char mname[999][26], name;
	int i, j, m, len, max = 0;
	int num[999], count[26] = {0};
	cin >> m;
	for (i = 0; i < m; i++)
	{
		cin >> num[i] >> mname[i];
		len = strlen(mname[i]);
		for (j = 0; j < len; j++)
		{
			count[mname[i][j] - 'A']++;
		}
	}
	for (i = 0; i < 26; i++)
	{
		if (count[i] > max)
		{
			max = count[i];
			name = i + 'A';
		}
	}
	cout << name << endl << max << endl;
	for (i = 0; i < m; i++)
	{
		len = strlen(mname[i]);
		for (j = 0; j < len; j++)
		{
			if (mname[i][j] == name)
			{
				cout << num[i] << endl;
				break;
			}
		}
	}
	return 0;
}


struct book
{
int number;
char a[26];
int la;
struct book *next;
};

struct book *insert(struct book *head,struct book *temp)
{
struct book *p0,*p1,*p2;
p1=head;
p0=temp;
if(head==NULL)
 {head=p0;p0->next=NULL;}
else
 {
 while(p1->next!=NULL)
 {p1=p1->next;}
 p1->next=p0;
 p0->next=NULL;
 }
return head;
}

void main()
{
struct book *p,*temp,*head=NULL;
int i,m,max;
int b[26]={0};
char writer;
scanf("%d",&m);
for(i=0;i<m;i++)
{
temp=(struct book *)malloc(sizeof(struct book));
scanf("%d ",&temp->number);
gets(temp->a);

temp->la=strlen(temp->a);
temp->next=NULL;
head=insert(head,temp);
}

p=head;
while(p!=NULL)
{
for(i=0;i<p->la;i++)
b[p->a[i]-65]++;
p=p->next;

}
max=b[0];writer=65;
for(i=0;i<26;i++)
{
 if(b[i]>max)
 {
  max=b[i];
  writer=i+65;
 }
}

printf("%c\n%d\n",writer,max);

p=head;
while(p!=NULL)
{
for(i=0;i<p->la;i++)
if(p->a[i]==writer)
{printf("%d\n",p->number);break;}
p=p->next;
}

}


struct book
{
	int num;
	char zz[32];
    struct book *next;
};
struct book *creat(int n)
{
	struct book *head,*p1,*p2;
	int i;
	p1=p2=(struct book *)malloc(LEN);
	scanf("%d %s",&p1->num,p1->zz);
	head=NULL;
	for(i=0;i<n-1;i++)
	{
		if(i==0) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct book *)malloc(LEN);
		scanf("%d %s",&p1->num,p1->zz);
	}
	p2->next=p1;
	p1->next=NULL;
	return (head);
}
void search(struct book *head,int n)
{
	int *p[26],i,j;
	struct book *q=head;
	for(i=0;i<26;i++)
	{
		p[i]=(int *)malloc(sizeof(int));
		*p[i]=0;
	}
    for(i=0;i<n;i++)
	{
		for(j=0;(q->zz)[j]!='\0';j++)
		{
			(*p[(q->zz)[j]-'A'])++;
		}
		q=q->next;
	}
	q=head;
	int max=*p[0],k=0;
	for(i=1;i<26;i++)
	{if(*p[i]>max){max=*p[i];k=i;}}
	printf("%c\n%d",'A'+k,max);
	for(i=0;i<n;i++)
	{
		for(j=0;(q->zz)[j]!='\0';j++)
		{
			if((q->zz)[j]=='A'+k)
				printf("\n%d",q->num);
		}
		q=q->next;
	}
}

void main()
{
	int n;
	scanf("%d",&n);
	struct book *head;
	head=creat(n);
	search(head,n);
}


int main()
{char ma='A';
int cnt[128]={0};
int i,j,n;
struct s
{int id;
char au[27];
}bk[1000];

scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d%s",&bk[i].id,bk[i].au);
for(j=0;bk[i].au[j]!='\0';j++)
{cnt[bk[i].au[j]]++;
if(cnt[bk[i].au[j]]>cnt[ma]){ma=bk[i].au[j];}
}
}
printf("%c\n%d\n",ma,cnt[ma]);
for(i=0;i<n;i++)
{
	if(strchr(bk[i].au,ma)){printf("%d\n",bk[i].id);}
}
return 0;

}


int main()
{
    int n,i,j,max=0;
    int zuozhe[26]={0};
    char maxer;
    struct book
    {
         int num;
         char author[26];
    }
    shu[1000];
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf("%d %s",&shu[i].num,shu[i].author);
        for (j=0;j<26;j++)
           zuozhe[shu[i].author[j]-65]++;
    }
    for (j=0;j<26;j++)
        if (zuozhe[j]>max)
        {
            max=zuozhe[j];
            maxer=j+65;
        }
    printf("%c\n%d\n",maxer,max);
    for (i=0;i<n;i++)
        for (j=0;j<26;j++)
            if (shu[i].author[j]==maxer)
            {
                printf("%d\n",shu[i].num);
                continue;
            }
}


struct zuozhe
        {
                int m;
                char q;
                char shu[1001][5];
        }zuozhe[26],t;
int main()
{
        int n;
        cin>>n;
        int i;
        char xingming[30];
        char bianhao[5];
        char zimu[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for(i=0;i<26;i++)
                zuozhe[i].m=0;
        for(i=1;i<=n;i++)
        {
                cin>>bianhao>>xingming;
                int j,k;
                for(j=0;xingming[j]!='\0';j++)
                {
                        for(k=0;k<26;k++)
                        {
                                if(xingming[j]==zimu[k])
                                {
                                        zuozhe[k].m++;
                                        zuozhe[k].q=zimu[k];
                                        strcpy(zuozhe[k].shu[zuozhe[k].m],bianhao);
                                        break;
                                }
                        }
                }
        }
        int min=0;
        int maxnum = 0;
        for(i=0;i<26;i++)
        {

                        if(zuozhe[i].m>maxnum)
                        {
                                maxnum = zuozhe[i].m;
                                min = i;
                        }
        }
        cout<<zuozhe[min].q<<endl<<zuozhe[min].m<<endl;
        for(i=1;i<=zuozhe[min].m;i++)
        {
                cout<<zuozhe[min].shu[i]<<endl;
        }
        return 0;
}


struct information
{
	int num;
	char author[26];
}*a;
void main()
{
	int n,i,j,m,s[26]={0},max=0,p;
	scanf("%d",&n);
	a=(struct information *)malloc(sizeof(struct information)*n);
	for(i=0;i<n;i++) scanf("%d%s",&a[i].num,a[i].author);
	for(i=0;i<n;i++)
	{
		for(j=0;a[i].author[j]!='\0';j++)
		{
			m=a[i].author[j]-'A';s[m]++;
		}
	}
	for(i=0;i<26;i++)
	{
		if(max<s[i]) {max=s[i];p=i;}
	}
	printf("%c\n%d\n",'A'+p,s[p]);
	for(i=0;i<n;i++)
	{
		for(j=0;j<26;j++)
		{
			if(a[i].author[j]=='A'+p) {printf("%d\n",a[i].num);break;}
		}
	}
}


struct book
{
       char number[20];
       char name[26];
}books[1000];

main()
{
       int n,i,j;int count[26]={0};int temp,base,k=0;char author;int pd=0,N=0;
       scanf("%d",&n);
       for(i=0;i<n;i++)
       {
                       scanf("%s %s",&books[i].number,&books[i].name);
       }
       for(i=0;i<n;i++)
       {
                       for(j=0;books[i].name[j]>='A'&&books[i].name[j]<='Z';j++)
                       {
                                 temp=books[i].name[j]-'A';
                                 count[temp]++;
                       }
       }
       base=count[0];
       for(i=0;i<26;i++)
       {
                        if(count[i]>base)
                        {base=count[i];k=i;}
       }
       author='A'+k;
       printf("%c\n",author);
        for(i=0;i<n;i++)
       {               pd=0;
                       for(j=0;books[i].name[j]>='A'&&books[i].name[j]<='Z';j++)
                       {

                              if(books[i].name[j]==author)
                              pd=1;
                       }
                       if(pd==1)
                       N++;
       }
       printf("%d\n",N);
       for(i=0;i<n;i++)
       {               pd=0;
                       for(j=0;books[i].name[j]>='A'&&books[i].name[j]<='Z';j++)
                       {

                              if(books[i].name[j]==author)
                              pd=1;
                       }
                       if(pd==1)
                       printf("%s\n",books[i].number);
       }

}


void main()
{
	int i,n,j,t,m,a[26]={0},book[999],max;
    char writer[999][26],maxwriter;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %s",&book[i],writer[i]);
		m=strlen(writer[i]);
		for(j=0;j<m;j++)
		{
			t=writer[i][j]-'A';
			a[t]++;
		}
	}
	max=0;
	maxwriter='A';
	for(i=0;i<26;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
			maxwriter='A'+i;
		}
	}
	printf("%c\n%d\n",maxwriter,max);
	for(i=0;i<n;i++)
	{
		for(j=0;j<strlen(writer[i]);j++)
		{
			if(writer[i][j]==maxwriter)
			{
				printf("%d\n",book[i]);
				break;
			}
		}
	}
}


struct aut
{
	char name;
	int num;
	int id[1000];
};

struct aut author[26];

int main()
{
	int m,i,j,ID,max=0,maxauthor,k[26]={0};
	char c[27];
	scanf("%d",&m);
	for(i=0;i<26;i++){
		author[i].name='A'+i;
		author[i].num=0;
	}
	for(i=0;i<m;i++){
		scanf("%d %s",&ID,c);
		for(j=0;c[j];j++){
			author[c[j]-'A'].id[k[c[j]-'A']]=ID;
			k[c[j]-'A']++;
			author[c[j]-'A'].num++;
		}
	}
	for(i=0;i<26;i++){
		if(author[i].num>max){
			max=author[i].num;
			maxauthor=i;
		}
	}
	printf("%c\n%d\n",author[maxauthor].name,author[maxauthor].num);
	for(i=0;i<author[maxauthor].num;i++){
		printf("%d\n",author[maxauthor].id[i]);
	}

	return 0;
}


struct book
{
	int num;
	char name[20];
};
void main()
{
	struct book c[1000];
	int i,j,n,k,max,l,d[26],a;
	int b[26]={0};
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
	scanf("%d %s",&c[k].num,c[k].name);
	for(i=0;i<strlen(c[k].name);i++)
	{
		for(j=0;j<26;j++)
		{
			if('A'+j==c[k].name[i])
				break;
        }
		b[j]=b[j]+1;
	}
	}
	for(a=0;a<26;a++)
		d[a]=b[a];
     max=b[0];
	 for(l=0;l<26;l++)
	 if(b[l]>max)
		 max=b[l];
	  for(a=0;a<26;a++)
	{
		if(d[a]==max)
			break;
	}
	printf("%c\n",'A'+a);
	 printf("%d\n",max);

	 for(k=0;k<n;k++)
	 {
        for(i=0;i<strlen(c[k].name);i++)
	{
			if('A'+a==c[k].name[i])
			{
	            printf("%d\n",c[k].num);
				break;
			}
	}
	 }
}


int alpha[26]={0};
struct library
{
	int num;
	char authors[27];
}books[999];
void addauthor(char string[])
{
	int i=0;
	do
	{ alpha[string[i]-'A']++;
	i++;
	}
	while(string[i]!='\0');
}
void hewroteit(struct library book,int maxalpha)
{
	int i;
	for(i=0;book.authors[i]!='\0';i++)
	{
		if(book.authors[i]-'A'==maxalpha)
		{
			printf("%d\n",book.num);
			break;
		}
	}
}
int main()
{
	int m;
	scanf("%d",&m);
	int i;
	for(i=0;i<m;i++)
		scanf("%d %s",&books[i].num,books[i].authors);
	for(i=0;i<m;i++)
		addauthor(books[i].authors);
	int max=0,maxalpha=0;
	for(i=0;i<26;i++)
	{
		if (alpha[i]>max)
		{
			max=alpha[i];
			maxalpha=i;
		}
	}
	printf("%c\n%d\n",'A'+maxalpha,max);
	for(i=0;i<m;i++)
	{
		hewroteit(books[i],maxalpha);
	}
	return 0;
}


struct student{
	char name[27];
	int anum;
	int num;
	struct student *next;
};
int n;
int i;
char c;

struct student *creat()
{
	struct student *head;
	head=(struct student *)malloc(LEN);
	if(n==0)
		head=NULL;
	else
	{
		scanf("%d",&head->num);
		for(i=0;(c=getchar())!='\n';i++)
		{
			head->name[i]=c;
		}
		head->anum=i;
		head->next=NULL;
	}
	return(head);
}

int main()
{
	struct student *head,*p1,*p2,*p;
	char l[200]={0};
	int j;
	int max=0;
	int lmax;

	scanf("%d",&n);
	head=creat();
	p1=p2=head;

	for(i=1;i<n;i++)
	{
		{
			p1=(struct student *)malloc(LEN);
			p2->next=p1;
			p2=p1;

			scanf("%d",&p2->num);
			for(j=0;(c=getchar())!='\n';j++)
			{
				p2->name[j]=c;
			}
			p2->anum=j;

			p2->next=NULL;
		}
	}

	p=head;
	for(j=0;j<n;j++)
	{
		for(i=0;i<p->anum;i++)
		{
			l[p->name[i]]=l[p->name[i]]+1;
		}
		p=p->next;
	}

	for(i=65;i<=90;i++)
	{
		if(l[i]>max)
		{
			max=l[i];
			lmax=i;
		}

	}
	printf("%c\n%d\n",lmax,max);

	p=head;
	for(j=0;j<n;j++)
	{
		for(i=0;i<p->anum;i++)
		{
			if(p->name[i]==lmax)
				printf("%d\n",p->num);
		}
		p=p->next;
	}

	return 0;
}


int main()
{
	int booknumber;
	int order[1000];
	char author[1000][27];
	char single_author[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int author_booknumber[26]={0};
	int i,j,k;
	int tmp;

	scanf("%d",&booknumber);

	for(i=0;i<booknumber;i++)
	{
		scanf("%d%s",&order[i],author[i]);
		for(j=0;j<strlen(author[i]);j++)
		{
			for(k=0;k<26;k++)
			{
				if(author[i][j]==single_author[k])
				{
					author_booknumber[k]++;
					break;
				}
			}
		}
	}
	tmp=0;

	for(i=1;i<26;i++)
	{
		if(author_booknumber[i]>author_booknumber[tmp])
			tmp=i;
	}
	printf("%c\n",single_author[tmp]);
	printf("%d\n",author_booknumber[tmp]);

	for(i=0;i<booknumber;i++)
	{
		for(j=0;j<strlen(author[i]);j++)
		{
			if(author[i][j]==single_author[tmp])
			{
				printf("%d\n",order[i]);
				break;
			}
		}
	}

	return 0;
}


int main()
{
struct book
{
    int No;
    char name[27];
}b[1000];
    int i,j,m;
    scanf("%d",&m);
    printf("\n");
    for(i=0;i<m;i++){
        scanf("%d ",&b[i].No);
        scanf("%s",b[i].name);
    }
    int n,l,a[26]={0};
    for(i=0;i<m;i++){
        l=strlen(b[i].name);
        for(j=0;j<l;j++){
            n=b[i].name[j];a[n-65]++;
        }
    }
    int max=0,x;
    for(i=0;i<26;i++){
        if(a[i]>max){max=a[i];x=i;}
    }
    printf("%c\n%d",x+65,max);
    for(i=0;i<m;i++){
        l=strlen(b[i].name);
        for(j=0;j<l;j++){
            if(b[i].name[j]==x+65){printf("\n%d",b[i].No);break;}
        }
    }
    return 0;
}


struct person{
    int num;
    int book[1000];
};
struct person p[26];
int n,m,i,j,k;
char str[30];
int main(){
    memset(p,0,sizeof(p));
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%s",&m,str);
        for(j=strlen(str)-1;j>=0;j--)
            if(str[j]>='A'&&str[j]<='Z'){
                k=p[str[j]-'A'].num++;
                p[str[j]-'A'].book[k]=m;
            }
    }
    m=0;
    for(i=1;i<26;i++)
        if(p[i].num>p[m].num)
            m=i;
    printf("%c\n",'A'+m);
    printf("%d\n",p[m].num);
    for(i=0;i<p[m].num;i++)
        printf("%d\n",p[m].book[i]);
    return 0;
}


int main(int argc, char* argv[])
{
	struct book{
		int num;
		char author[27];
	}B[1000];
	char A;
	int m,i,j,a[26]={0},max;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d%s",&B[i].num,B[i].author);
	}
	for(i=0;i<m;i++){
		for(j=0;;j++){
			if(B[i].author[j]==0)
				break;
			else
				a[B[i].author[j]-65]++;
		}
	}
	max=a[0];
	A=65;
	for(i=0;i<26;i++){
		if(a[i]>max){
			max=a[i];
			A=i+65;
		}
	}
	printf("%c\n%d",A,max);
	for(i=0;i<m;i++){
		for(j=0;;j++){
			if(B[i].author[j]==0)
				break;
			if(B[i].author[j]==A)
				printf("\n%d",B[i].num);
		}
	}
	return 0;
}


struct book
{
    char writer[32];
    int id;
    struct book *next;
};
struct book *create(int m)
{
     struct book *head=NULL,*p1,*p2;
     int i;
     p1=p2=(struct book*)malloc(Len);
     scanf("%d %s",&p1->id,p1->writer);
     p1->next=NULL;
     head=p1;
     p2=p1;
     for(i=1;i<m;i++)
        {
            p1=(struct book*)malloc(Len);
             scanf("%d %s",&p1->id,p1->writer);
            p1->next=NULL;
            p2->next=p1;
            p2=p1;
        }
         return head;
}
int main()
{
    struct book *head,*p;
    int m,i,*q1,*q2,j;
    q1=(int*)malloc(26*sizeof(int*));
      q2=q1;
    for(i=0;i<26;i++)
      q1[i]=0;
    q1=q2;
    scanf("%d",&m);
    head=create(m);
    p=head;
    for(i=0;i<m;i++)
    {
       for(j=0;p->writer[j]!='\0';j++)
       q1[p->writer[j]-'A']++;
       p=p->next;
    }
    q1=q2;
    int max=0;
    char maxm='A';
    for(i=0;i<26;i++)
      if(max<q1[i]) {max=q1[i];maxm=i+'A';}
      printf("%c\n%d",maxm,max);
    for(i=0,p=head;i<m;i++,p=p->next)
      for( j=0;p->writer[j]!='\0';j++)
        if(p->writer[j]==maxm) printf("\n%d",p->id);
}


struct books
{
	int num;
	char author[27];
}book[999];
void main()
{
    int f(struct books *p,int n,char z);
	int i,n,j,x[26],k,max;
	char z;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d%s",&book[i].num,book[i].author);
	for(z='A',i=0;z<='Z';z++,i++)x[i]=f(book,n,z);
	for(i=1,max=x[0],k=0;i<26;i++)if(x[i]>max){max=x[i];k=i;}
    printf("%c\n%d\n",k+65,max);
	for(i=0;i<n;i++)for(j=0;book[i].author[j]!='\0';j++)
		if(book[i].author[j]==k+65){printf("%d\n",book[i].num);break;}
}
int f(struct books *p,int n,char z)
{
	int m=0,i,j;
	for(i=0;i<n;i++)for(j=0;(p+i)->author[j]!='\0';j++)
		if((p+i)->author[j]==z){m++;break;}
	return m;
}


struct book
{
	int num;
	char writer[20];
	struct book *next;
};
int main()
{
	int n,i,j,m,k,c[26],max;//c[26]???????????//
	char a[26];//a[26]??????//
	scanf("%d",&m);
	struct book *p1,*p2,*head;
	for(i=0;i<m;i++)
	{
		p1=(struct book*)malloc(Len);
		if(i==0)
		{
			head=p1;
		}
		else
		{
			p2->next=p1;
		}
		p2=p1;
		scanf("%d %s",&p1->num,p1->writer);
	}
	p2->next=NULL;
	p1=head;
	for(i=0;i<26;i++)
	{
		a[i]=i+65;
		c[i]=0;
	}
	for(j=0;j<m;j++)
	{
		for(i=0;i<26;i++)
		{
			n=strlen(p1->writer);
			for(k=0;k<n;k++)
			{
				if(a[i]==p1->writer[k])
				{
					c[i]++;
				}
			}
		}
		p1=p1->next;
	}
	max=0;
	for(i=0;i<26;i++)
	{
		if(c[i]>c[max])
		{
			max=i;
		}
	}
	printf("%c\n%d\n",a[max],c[max]);
	p1=head;
	for(i=0;i<m;i++)
	{
		n=strlen(p1->writer);
		for(j=0;j<n;j++)
		{
			if(p1->writer[j]==a[max])
			{
				printf("%d\n",p1->num);
			}
		}
		p1=p1->next;
	}
	return 0;
}


int main(){
    struct book{
        int num;
        char name[26];
    };
    int n,i,j,a[26]={0},len[1000],k,max=0;
    struct book list[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&list[i].num);
        scanf("%s",list[i].name);
        len[i]=strlen(list[i].name);
    }
    for(i=0;i<26;i++){
        for(j=0;j<n;j++){
            for(k=0;k<len[j];k++){
                if(list[j].name[k]==i+65){
                    a[i]++;
                    break;
                }
            }
        }
    }
    for(i=0;i<26;i++){
        if(a[i]>max){
            max=a[i];
            k=i;
        }
    }
    printf("%c\n",k+65);
    printf("%d\n",max);
    for(i=0;i<n;i++){
        for(j=0;j<len[i];j++){
            if(list[i].name[j]==k+65){
                printf("%d\n",list[i].num);
            }
        }
    }
    return 0;
}


int main()
{
    int n,i,j,k;
    scanf("%d\n",&n);

    struct book
    {
    int num;
    char name[26];
     }book[999];

    for(i=0;i<n;i++)
    { scanf("%d %s\n",&book[i].num,book[i].name);
     }

    struct author
    {
    char l;
    int count;
     }au[26];

    for(i=0;i<26;i++)
    { au[i].l=65+i;
      au[i].count=0;
     }

    for(i=0;i<26;i++)
    { for(j=0;j<n;j++)
        {  for(k=0;k<26;k++)
             {if(au[i].l==book[j].name[k])
                 {au[i].count++;
                  break;
                  }
             }
         }
    }

    int max=0;
    for(i=1;i<26;i++)
    { if(au[max].count<au[i].count)
           max=i;
     }
    printf("%c\n%d\n",au[max].l,au[max].count);

    for(j=0;j<n;j++)
    { for(k=0;k<26;k++)
      {
       if(au[max].l==book[j].name[k])
          { printf("%d\n",book[j].num);
            break;
           }
       }
     }
    return 0;
}


struct book
{
	int num;
	char *name;
	struct book *next;
}

main()
{
	int n,i;
	scanf("%d",&n);
	struct book *p1,*p2,*head;
	p1=len;
	head=p1;
	for(i=0;i<n;i++)
	{
		p1->name=(char *)malloc(26*1);
		scanf("%d %s",&p1->num,p1->name);
		p2=len;
		p1->next=p2;
		p1=p2;
	}
	p1=p2=head;
	int *a;
	a=(int *)malloc(26*4);
	for(i=0;i<26;i++)
		*(a+i)=0;
	int j;
	int l;
	for(i=0;i<n;i++)
	{
		j=0;
		while(*(p1->name+j)!='\0')
		{
			l=*(p1->name+j)-'A';
			*(a+l)+=1;
			j+=1;
		}
		p1=p1->next;
	}
	int max=0,maxl;
	for(i=0;i<26;i++)
		if(*(a+i)>max)
		{
			max=*(a+i);
			maxl='A'+i;
		}
	printf("%c\n%d\n",maxl,max);
	p1=p2=head;
	for(i=0;i<n;i++)
	{
		j=0;
		while(*(p1->name+j)!='\0')
		{
			if(*(p1->name+j)==maxl)
			{
				printf("%d\n",p1->num);
				break;
			}
			j+=1;
		}
		p1=p1->next;
	}
}


struct book
{
	int num;
	char author[27];
}book[1000];

void main()
{
	int m,i,j,k;
	char s[26];
	int w[26]={0};
	int len[1000];
	int max,most;
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&book[i].num,book[i].author);
	}
	for(i=0;i<26;i++)
	{
		s[i]='A'+i;
	}
	for(i=0;i<m;i++)
	{
		len[i]=strlen(book[i].author);
		for(j=0;j<len[i];j++)
		{
			for(k=0;k<26;k++)
			{
				if(book[i].author[j]==s[k])
					w[k]++;
			}
		}
	}
	max=w[0];
	most=0;
	for(i=0;i<26;i++)
	{
		if(w[i]>max)
		{
			max=w[i];
			most=i;
		}
	}
	printf("%c\n%d\n",s[most],max);
	for(i=0;i<m;i++)
	{
		len[i]=strlen(book[i].author);
		for(j=0;j<len[i];j++)
		{
			if(book[i].author[j]==s[most])
				printf("%d\n",book[i].num);
		}
	}
}


struct book
{
	int num;
	char name[27];
};
int main()
{
	int n,i,j,l,sum[26],t=0,T=0;struct book a[1000];memset(sum,0,sizeof(sum));char A;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> a[i].num >> a[i].name;
		l=strlen(a[i].name);
		for(j=0;j<l;j++)
		{
			sum[a[i].name[j]-'A']++;
		}
	}
	for(i=0;i<26;i++)
	{
		if(sum[i]>t)
		{
			t=sum[i];T=i;
		}
	}
	A='A'+T;
	cout << A << endl;
	cout << t << endl;
	for(i=0;i<n;i++)
	{
		for(j=0;j<27;j++)
		{
			if(a[i].name[j]==A)
				cout << a[i].num << endl;
		}
	}
	return 0;
}


struct book
{
	int id;
	char str[27];
}bo[1000];
struct people
{
	int name;
	int number;
	int book_number[1000];
}people[26];
int main ( )
{
	int n, i, j, k, m, max = 0;
	char a[27] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\0'};
	cin >> n;
	for(i = 0;i < n;i++)
	{
		cin >> bo[i].id >> bo[i].str;
	}
	for(i = 0;i < 26;i++)//???
	{
		people[i].number = 0;
	}
	for(i = 0;i < n;i++)
	{
		m = strlen(bo[i].str);
		for(j = 0;j < m;j++)
		{
			for(k = 0;k < 26;k++)//???????????
			{
				if(bo[i].str[j] == a[k])
				{
					people[k].book_number[people[k].number] = bo[i].id;
					people[k].number++;
				}
			}
		}
	}
	j = 0;
	for(i = 0;i < 26;i++)//?????????
	{
		if(people[i].number > max)
		{
			j = i;
			max = people[i].number;
		}
	}
	cout << a[j] << endl;
	cout << people[j].number << endl;
	for(i = 0;i < people[j].number;i++)
	{
		cout << people[j].book_number[i] << endl;
	}
	return 0;
}


main(){
	int i, sum[26]={0}, m, j, max=0, p;
	struct book{
		int num;
		char au[27];
		int l;
	};
	struct book bk[1000];
	scanf("%d", &m);
	for(i=0; i<m; i++){
		scanf("%d %s", &bk[i].num, bk[i].au);
		bk[i].l=strlen(bk[i].au);
		for(j=0; j<bk[i].l; j++){
			switch(bk[i].au[j]){
			case 'A': sum[0]+=1; break;
			case 'B': sum[1]+=1; break;
			case 'C': sum[2]+=1; break;
			case 'D': sum[3]+=1; break;
			case 'E': sum[4]+=1; break;
			case 'F': sum[5]+=1; break;
			case 'G': sum[6]+=1; break;
			case 'H': sum[7]+=1; break;
			case 'I': sum[8]+=1; break;
			case 'J': sum[9]+=1; break;
			case 'K': sum[10]+=1; break;
			case 'L': sum[11]+=1; break;
			case 'M': sum[12]+=1; break;
			case 'N': sum[13]+=1; break;
			case 'O': sum[14]+=1; break;
			case 'P': sum[15]+=1; break;
			case 'Q': sum[16]+=1; break;
			case 'R': sum[17]+=1; break;
			case 'S': sum[18]+=1; break;
			case 'T': sum[19]+=1; break;
			case 'U': sum[20]+=1; break;
			case 'V': sum[21]+=1; break;
			case 'W': sum[22]+=1; break;
			case 'X': sum[23]+=1; break;
			case 'Y': sum[24]+=1; break;
			case 'Z': sum[25]+=1; break;
			}
		}
	}
	for(i=0; i<26; i++){
		if(sum[i]>max){
			max=sum[i];
			p=i;
		}
		else;
	}
	printf("%c\n%d", p+65, max);
	for(i=0; i<m; i++){
		for(j=0; j<bk[i].l; j++){
			if(bk[i].au[j]==p+65){
				printf("\n%d", bk[i].num);
				break;
			}
			else;
		}
	}
}


void function(int,int);

int main()
{
   char s[200][100];
   int n[100],h[100],maxh[100];
   int a;
   int i,j,k,p;
   int num,maxnum=0;
   char c;

   scanf("%d",&a);
   for(i=0;i<a;i++)
   {
      scanf("%d%s",&n[i],s[i]);
   }

   for(j='A';j<='Z';j++)
   {
       num=0;
       for(i=0;i<a;i++)
       {
          for(k=0;k<strlen(s[i]);k++)
          {
             if(s[i][k]==j)
             {
                 num++;
                 h[num]=n[i] ;
             }
          }
       }
       if(num>maxnum)
       {
          c=j;
          maxnum=num;
          for(p=1;p<=maxnum;p++)
          {
             maxh[p]=h[p];
          }
       }
   }

   printf("%c\n%d\n",c,maxnum);
   for(p=1;p<=maxnum;p++)
   {
       printf("%d\n",maxh[p]);
   }
   return 0;

}


struct Article {
	int number;
	char author[26];
};

int main()
{
	struct Article book[1000];
	int m, i;
	int j, k;
	int c;
	int max = 0;
	int writer[26] = {0};

	scanf("%d",&m);
	for (i = 0; i < m; i++) {
		scanf("%d %s",&book[i].number,book[i].author);
	}

	for (i = 0; i < m; i++) {
		for (j = 0; j < 26; j++) {
			if (book[i].author[j] >= 'A' && book[i].author[j] <= 'Z') {
				c = book[i].author[j] - 'A';
				writer[c]++;
			}
		}
	}

	for (i = 0; i < 26; i++) {
		if (max < writer[i]) {
			max = writer[i];
		}
	}

	for (i = 0; i < 26; i++) {
		if (max == writer[i]) {
			printf("%c\n",i + 'A');
			printf("%d\n",max);
			for (j = 0; j < m; j++) {
				for (k = 0; k < 26; k++) {
					if (book[j].author[k] == i + 'A') {
						printf("%d\n",book[j].number);
					}
				}
			}
			break;
		}
	}
	return 0;
}


void main()
{
	struct ts
	{
		int sl;
		char zz[30];
		int zzsl;
		struct ts *next;
	};
	struct ts *p1,*p2,*head;
	int i,j,k,m,n,max,zzzdnum,num[100]={0};
	char zzzd;
	scanf("%d",&n);
	p1=p2=head=(struct ts *)malloc(sizeof(struct ts));
	scanf("%d %s",&p1->sl,p1->zz);
//	p1->zzsl=strlen(p1->zz);//?????
	for(i=1;i<n;i++)
	{
		p1=(struct ts *)malloc(sizeof(struct ts));
		scanf("%d %s",&p1->sl,p1->zz);
		p1->zzsl=strlen(p1->zz);
		p2->next=p1;
		p2=p1;
	}
	p1->next=0;
	for(i='A';i<='Z';i++)
	{
		p1=head;
		for(k=0;k<n;k++)
		{
			for(j=0;p1->zz[j]!='\0';j++)
			{
				if(p1->zz[j]==i)num[i]++;
			}
			p1=p1->next;
		}
	}
	max=0;
	for(i='A';i<='Z';i++)
	{
		max=max>num[i]?max:num[i];
	}
	for(i='A';i<='Z';i++)
	{
		if(num[i]==max)zzzd=i;//????????
	}
	printf("%c\n%d\n",zzzd,max);
	p1=head;
	zzzdnum=0;
	for(i=0;i<n;i++)
	{
		for(j=0;p1->zz[j]!='\0';j++)
		{
			if(p1->zz[j]==zzzd)
			{
				printf("%d\n",p1->sl);
			}
		}
		p1=p1->next;
	}
}


char name;
int num,k=0,t=0;
int nametimes[100]={0};
struct book
{
	unsigned int No;
	char Name[26];
}*p;
void operate()
{
	int i;
	for(i=65;i<91;i++)
		if(nametimes[i]>t)
		{
			t=nametimes[i];
			name=i;
		}
}
void print()
{
	struct book *pi;
	int i;
	printf("%c\n%d\n",name,t);
	for(pi=p;pi<p+num;pi++)
		for(i=0;pi->Name[i]!='\0';i++)
			if(pi->Name[i]==name)
			{
				if(k==0)
				{
					printf("%d",pi->No);
					k++;
				}
				else
					printf("\n%d",pi->No);
				break;
			}
}
main()
{
	scanf("%d",&num);
	struct book *pi;
	int i;
	p=(struct book*)malloc(num*sizeof(struct book));
	for(pi=p;pi<p+num;pi++)
	{
		scanf("%d %s",&pi->No,pi->Name);
		for(i=0;pi->Name[i]!='\0';i++)
			nametimes[(int)pi->Name[i]]++;
	}
	operate();
	print();
}


struct book
{
	int num;
	char author[26];
	struct book *next;
};
struct book *creat()
	{
		int n;
		scanf("%d",&n);
		int i=1;
		struct book *head,*p1,*p2;
		p1=(struct book*)malloc(LEN);
		scanf("%d %s",&p1->num,p1->author);
		p1->next=NULL;
		if(i>=n) {free(p1);head=NULL;return head;}
		else
		{head=p1;
		p2=p1;
		while(i<n)
		{p1=(struct book*)malloc(LEN);
		scanf("%d %s",&p1->num,p1->author);
		p1->next=NULL;
		i++;
		{p2->next=p1;p2=p1;}
		}
        p2->next=p1;
		p1->next=NULL;
		return head;
		}
	}
int max(char letter,struct book *head)
{
	int i,j,k;
	i=0;
	struct book *q;
	q=head;
	while(q!=NULL)
	{
		k=strlen(q->author);
		for(j=0;j<k;j++)
		{if((q->author)[j]==letter) i++;}
		q=q->next;
	}
	return i;
}

void outbook(char letter,struct book *head)
{
	int j,k;
	struct book *q;
	q=head;
	while(q!=NULL)
	{
		k=strlen(q->author);
		for(j=0;j<k;j++)
		{if((q->author)[j]==letter) printf("%d\n",q->num);}
		q=q->next;
	}
}
void main()
{
	int i,m,s;
	struct book *p0,*p1;
	p0=p1=creat();
	int sum[26];
	for(i=0;i<26;i++)
	{
		sum[i]=max(i+65,p0);
	}
	s=0;
	m=sum[0];
	for(i=0;i<26;i++)
	{
		if(sum[i]>m) {m=sum[i];s=i;}
	}
	printf("%c\n",s+65);
	printf("%d\n",m);
	outbook(s+65,p1);
}


int main()
{
	int bookno[100];
	char author[100][26];
	int numOfauthor[26] = {0};
	int nbook, max = 0, maxno;
	char maxauthor;
	cin >> nbook;
	int i, j;
	for ( i = 0; i < nbook; i ++)
	{
		cin >> bookno[i];
		cin.get();
		cin.getline(*(author + i), 26);
	}
	for ( i = 0; i < nbook; i ++)
		for ( j = 0; author[i][j] !='\0'; j ++)
		{
			numOfauthor[author[i][j] - 'A'] ++;
		}
	for ( i = 0; i < 26; i ++)
	{
		if ( numOfauthor[i] > max)
		{
			max = numOfauthor[i];
			maxno = i;
		}
	}
	maxauthor = maxno + 'A';
	cout << maxauthor << endl;
	cout << numOfauthor[maxno] << endl;
	for ( i = 0; i < nbook; i ++)
		for ( j = 0; author[i][j] != '\0'; j ++)
		{
			if ( author[i][j] == maxauthor )
				cout << bookno[i] << endl;
		}
	return 0;
}


int main()
{
	int m;
	cin>>m;
	int book[1000];
	char person[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char people[100][100];
	int i,j;
	int l;
    int t[100]={0};
	for(i=1;i<=m;i++)
	{
		cin>>book[i];
		cin>>people[i];
		l=strlen(people[i]);
		for(j=0;j<l;j++)
		{
			t[people[i][j]-'A']++;
		}

	}
	int max=0,tt;
	for(i=0;i<=26;i++)
	{
		if(t[i]>max)
		{
		 max=t[i];
		 tt=i;
	    }
	}
	cout<<person[tt]<<endl;
	cout<<max<<endl;
	int k;
	int already[26]={1};
	for(i=1;i<=m;i++)
	{

		l=strlen(people[i]);
		for(j=0;j<l;j++)
		{
			if(people[i][j]==person[tt])

			 {
			     cout<<book[i]<<endl;
			   for(k=0;k<l;k++)
			   {
			   	 if((people[i][k]!=person[tt])&&(already[people[i][k]-'A']!=0))
			   	 {
			   	 	//cout<<people[i][k]<<endl;
			   	 	already[people[i][k]-'A']=0;
			   	 }

			   }
			   break;

			 }
		}

	}
	return 0;

}


 struct book
   {
	   int num;
	   char writer[26];
   };
   int m;

int main()
{

  int i;
   scanf("%d",&m);
	book *p;
	p=(struct book*)malloc(sizeof(struct book)*m);
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&p[i].num,p[i].writer);
	}
	int j=0,u=0;
	int *a;
	a=(int *)malloc(sizeof(int)*150);
	for(i='A';i<='z';i++)
	a[i]=0;

	for(i='A';i<='Z';i++)
	{
		for(j=0;j<m;j++)
		{
			for(u=0;u<strlen(p[j].writer);u++)
			{
				if(i==p[j].writer[u])
				{
					a[i]++;
					break;
				}
			}
		}
	}
	int max=0;
	for(i='A';i<='Z';i++)
	{
		if(max<a[i])
			max=a[i];
	}
	for(i='A';i<='Z';i++)
	{
		if(max==a[i])
		break;
	}
	printf("%c\n%d\n",i,a[i]);
	for(j=0;j<m;j++)
	{
          for(u=0;u<strlen(p[j].writer);u++)
			{
				if(i==p[j].writer[u])
				{
				    printf("%d\n",p[j].num);
					break;
				}
			}
	}

   return 0;
}


void main()
{
	struct book
	{
		int num;
		char author[27];
		struct book *next;
	}*head = 0,*p1,*p2;
	int total,i,j,sumbook[26]={0},len,max;
	scanf("%d",&total);
	for(i=0;i<total;i++)
	{
		p1=(struct book *)malloc(sizeof(struct book));
		if(p1==0)
		{
			printf("Memory request failed!\n");
			exit(-1);
		}
		scanf("%d %s",&p1->num,p1->author);
		len = strlen(p1->author);
		for(j = 0;j<len;j++)
			sumbook[p1->author[j]-'A']++;
		if(head)
			p2->next=p1;
		else
			head=p1;
		p2=p1;
	}
	p1->next=0;
	len = 0;
	for(i = 0;i<26;i++)
	{
		if(sumbook[i]>len)
		{
			len = sumbook[i];
			max = i;
		}
	}
	printf("%c\n%d\n",max+'A',sumbook[max]);
	max += 'A';
	for(p1=head;p1;p1=p1->next)
	{
		len = strlen(p1->author);
		for(i = 0;i<len;i++)
		{
			if(p1->author[i]==max)
			{
				printf("%d\n",p1->num);
				break;
			}
		}
	}
}


struct a
{
	int number;
	char author[26];
}b[100];
int main()
{
	int L[26]={0};
	int n=0;
	int max=0;
	int p=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i].number;
		cin>>b[i].author;
		for(int j=0;b[i].author[j]!='\0';j++)
			L[b[i].author[j]-'A']++;
	}
	for(int i=0;i<26;i++)
		if(max<L[i])
		{
			p=i;
			max=L[i];
		}
	cout<<(char)(p+'A')<<endl;
	cout<<max<<endl;
	for(int i=0;i<n;i++)
	{
		for(int j=0;b[i].author[j]!='\0';j++)
		{
			if(b[i].author[j]-p=='A')
			{
				cout<<b[i].number<<endl;
				break;
			}
		}
	}
	return 0;
}


struct  book
{
    int  num;
    char  name[27];
    struct  book  *next;
};
   int  m;
struct  book   *head;

struct   book  *setup()
{   int  t=0;
    struct  book  *head,*p1,*p2;
    head=p1=p2=(struct  book  *)malloc(sizeof  (struct  book));
    scanf("%d %s",&p1->num,p1->name);
    while(t<m)
    {   t++;
        p2->next=p1;
        p2=p1;
        p1=(struct  book  *)malloc(sizeof(struct  book));
        scanf("%d %s",&p1->num,p1->name);
    }
    p2->next=NULL;

    return(head);
}
   int   k=0,max=0;
void   found(struct  book  *p)
{     int  i,j;
      p=head;
      int  *pi;
      pi=(int *)malloc(sizeof(int)*26);
      for(i=0;i<26;i++)  *(pi+i)=0;
      for(i=0;i<m;i++)
         {
              for(j=0;p->name[j]!='\0';j++)
              {
                         (*(pi+(p->name[j]-'A')))++;
              }
             p=p->next;
         }
         for(j=0;j<26;j++)
          {
                  if(*(pi+j)>max){
                   max=*(pi+j);
                   k=j;
                   }
          }

}
      int  main()
{   int  i,j;
    scanf("%d",&m);
    struct book *p;
     head=p=setup();
     found(p);
     printf("%c\n%d\n",(k+'A'),max);
     p=head;
     for(i=0;i<m;i++)
        {for(j=0;p->name[j]!='\0';j++)
           if(p->name[j]==k+'A'){
           printf("%d\n",p->num);
           break;
           }
           p=p->next;
        }
}


int a[30]={0},b[30][1000];
struct stu
{
	int num;
	char name[30];

	struct stu *next;
};
struct stu *creat(int n)
{
	struct stu *p1,*p2,*head;
	int i=0;
	p1=p2=(struct stu *)malloc(sizeof(struct stu));
	scanf("%d %s",&p1->num,p1->name);
	head=0;
	for(i=0;i<n;i++)
	{
		if(i==0)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		if(i<n-1)
		{
			p1=(struct stu *)malloc(sizeof(struct stu));
			scanf("%d %s",&p1->num,p1->name);
		}
	}
	p2->next=0;
	return head;
}
int check(struct stu *head,int n)
{
	int i,j,s,d=0,f=0;
	char *t;
	struct stu *p;
	p=head;
	for(i=0;i<n;i++,p=p->next)
	{
		s=strlen(p->name);
		t=p->name;
		for(j=0;j<s;j++)
		{
			d=t[j]-64;
			a[d]++;
			b[d][a[d]-1]=p->num;
		}
	}
	for(i=1;i<=26;i++)
	{
		for(j=1,f=0;j<=26;j++)
		{
		    if(a[i]<a[j])
			{
				f=1;
				break;
			}
		}
		if(f==0)
			break;
	}
	return i;
}
void main ()
{
	struct stu *head;
	int i,j,n;
	scanf("%d",&n);
	head=creat(n);
	i=check(head,n);
	printf("%c\n%d\n",i+64,a[i]);
	for(j=0;j<a[i];j++)
		printf("%d\n",b[i][j]);

}


struct BOOK{
	int id;
	int author[26];
};
int main(){
	struct BOOK book[1000];
	int countauthor[26];
	int n,i,j,minusA,no,count,max=0,maxau;
	char input[30];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<26;j++){
			book[i].author[j]=0;
		}
	}// refresh data: each book-->all authors initiate with 0
	for(i=0;i<n;i++){
		scanf("%d",&book[i].id);
		scanf("%s",&input);
		no=strlen(input);
		for(j=0;j<no;j++){
			minusA=(input[j]-'A');
			book[i].author[minusA]++;
		}
	}
	for(i=0;i<26;i++){
		count=0;
		for(j=0;j<n;j++){
			if(book[j].author[i]==1)
				count++;
		}
		countauthor[i]=count;
	}
	for(i=0;i<26;i++){
		if(max<countauthor[i])
			max=countauthor[i];
	}// to find max
	for(i=0;i<26;i++){
		if(countauthor[i]==max)
			maxau=i;
	}//to find which author	has maximum number of book
	printf("%c\n%d\n",(maxau+'A'),max);
	for(i=0;i<n;i++){
		if(book[i].author[maxau]==1){
			printf("%d\n",book[i].id);
		}
	}
	return 0;
}


int main()
{
	int m,i,j,max=0;
	int Q[26]={0};
	struct
	{
		int num;
		char name[27];
	}book[1000];
	scanf("%d",&m);
	for(i=0;i<m;i++)
		scanf("%d %s",&book[i].num,book[i].name);
	for(i=0;i<m;i++)
	{
		for(j=0;j<strlen(book[i].name);j++)
		{
			switch(book[i].name[j])
			{
				case 'A':
				Q[0]++;
				break;
				case 'B':
				Q[1]++;
				break;
				case 'C':
				Q[2]++;
				break;
				case 'D':
				Q[3]++;
				break;
				case 'E':
				Q[4]++;
				break;
				case 'F':
				Q[5]++;
				break;
				case 'G':
				Q[6]++;
				break;
				case 'H':
				Q[7]++;
				break;
				case 'I':
				Q[8]++;
				break;
				case 'J':
				Q[9]++;
				break;
				case 'K':
				Q[10]++;
				break;
				case 'L':
				Q[11]++;
				break;
				case 'M':
				Q[12]++;
				break;
				case 'N':
				Q[13]++;
				break;
				case 'O':
				Q[14]++;
				break;
				case 'P':
				Q[15]++;
				break;
				case 'Q':
				Q[16]++;
				break;
				case 'R':
				Q[17]++;
				break;
				case 'S':
				Q[18]++;
				break;
				case 'T':
				Q[19]++;
				break;
				case 'U':
				Q[20]++;
				break;
				case 'V':
				Q[21]++;
				break;
				case 'W':
				Q[22]++;
				break;
				case 'X':
				Q[23]++;
				break;
				case 'Y':
				Q[24]++;
				break;
				case 'Z':
				Q[25]++;
				break;
			}
		}
	}
	for(i=1;i<26;i++)
	{
		if(Q[i]>Q[max])
			max=i;
	}
	printf("%c\n%d\n",max+65,Q[max]);
	for(i=0;i<m;i++)
	{
		for(j=0;j<strlen(book[i].name);j++)
		{
			if(book[i].name[j]==max+65)
			{
				printf("%d\n",book[i].num);
				break;
			}
		}
	}
	return 0;
}


struct j
{
	int bianhao;
	char zuozhe[100];
};
main()
{
	int m,i,l,k,z,max=0;
	int shumu[26];
	scanf("%d",&m);
	struct j * a;
	a=(struct j *)malloc(m*sizeof(j));
	for(i=0;i<m;i++)
	{
		scanf("%d %s",&a[i].bianhao,a[i].zuozhe);
	}
	for(z=0;z<26;z++)
	{
		shumu[z]=0;
	for(i=0;i<m;i++)
	{
		char * p;
		p=a[i].zuozhe;
		l=strlen(a[i].zuozhe);
		for(k=0;k<l;k++)
		{
			if(p[k]=='A'+z)
				shumu[z]++;
		}
	}

    }
     for(z=0;z<26;z++)
	 {
        if(shumu[z]>max)
			max=shumu[z];
	 }
	 for(z=0;z<26;z++)
	 {
		 if(shumu[z]==max)
		 {

			 printf("%c\n%d\n",z+'A',max);
			 for(i=0;i<m;i++)
	{
		char * p;
		p=a[i].zuozhe;
		l=strlen(a[i].zuozhe);
		for(k=0;k<l;k++)
		{
			if(p[k]=='A'+z)
				printf("%d\n",a[i].bianhao);
		}
	}
			 break;
		 }
	 }

}


//#define NULL 0
struct stu
{
	int num;
	char c[26];
	struct stu *next;
};

struct stu* create(int m)
{
	struct stu *p1,*p2,*xhead;
	p1=(struct stu *)malloc(LEN);
	scanf("%d %s",&p1->num,p1->c);
	p2=p1;
	xhead=p1;

	while(m-1)
	{
		m--;
		p1=(struct stu*)malloc(LEN);
		scanf("%d %s",&p1->num,p1->c);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return xhead;
}

int stas(int b[])
{
		int j,max=0,indexx=0;
		for(j=0;j<26;j++)
		if(b[j]>max)
		{
			max=b[j];
			indexx=j;
		}
	printf("%c\n%d\n",indexx+65,max);
	//for(j=0;j<26;j++)
		//printf("%d ",b[j]);
	return indexx;
}

struct stu* search(struct stu* yhead,int y)
{
	struct stu *q;
	int sum=0,k;
	char *i;
	char s[20],s0[20]={'\0'};
	q=yhead;
	while(q)
	{
		strcpy(s,q->c);
		k=strlen(s);
		for(i=s;i<i+k;i++)
			if(*i==y+65)
				sum++;
		strcpy(s,s0);
		q=q->next;
	}
	printf("%d\n",sum);
	return 0;
}

struct stu* print(struct stu* zhead,int z)
{
	struct stu* q;
	int k;
	char *i;
	char s[20],s0[20]={'\0'};
	q=zhead;
	while(q)
	{
		strcpy(s,q->c);
		k=strlen(s);
		for(i=s;i<s+k;i++)
			if(*i==z+65)
			{
				printf("%d\n",q->num);
				break;
			}
		strcpy(s,s0);
		q=q->next;
	}
	return 0;
}

int main()
{
	int n,index;
	int a[26],k,t,i;
	char s[20],s0[20]={'\0'};
	struct stu *p,*head;
	memset(a,0,sizeof(a));

	scanf("%d",&n);
	head=create(n);
	p=head;
	while(p)
	{
		strcpy(s,p->c);
		//printf("%s ",s);
		k=strlen(s);
		//printf("%d ",k);
		for(i=0;i<k;i++)
		{
			//printf("%c ",s[i]);
			t=s[i]-65;
			a[t]++;
		}
		//for(t=0;t<26;t++)
			//printf("%d ",a[t]);
		strcpy(s,s0);
		p=p->next;
	}

	index=stas(a);
	//search(head,index);
	print(head,index);
	return 0;
}


struct book
{
  char num[500];
  char s[50];
  struct book *next;
};
void main()
{
  struct book *head;
  struct book *p1,*p2;
  int m,mi,i,j,k,max,found;
  int aut[26]={0};
  scanf("%d",&m);
  p1=(struct book*)malloc(LEN);
  scanf("%s %s",p1->num,p1->s);
  for(i=0;i<strlen(p1->s);i++)
	  aut[(p1->s)[i]-'A']++;
  p1->next=NULL;

  head=p2=p1;

  for(mi=2;mi<=m;mi++)
  {
    p1=(struct book*)malloc(LEN);
    scanf("%s %s",p1->num,p1->s);
    for(i=0;i<strlen(p1->s);i++)
	  aut[(p1->s)[i]-'A']++;

	p2->next=p1;
	p2=p1;
  }
  p2->next=NULL;

  max=0;
  for(i=0;i<26;i++)
	  if(aut[i]>max)
	  {
        k=i;
		max=aut[i];
	  }

  printf("%c\n",k+65);
  printf("%d\n",aut[k]);

  p1=head;
  for(i=1;i<=m;i++)
  {
    found=0;
	for(j=0;j<strlen(p1->s);j++)
		if((p1->s)[j]==k+65)
		{
          found=1;
		  break;
		}
	if(found==1) printf("%s\n",p1->num);
	p1=p1->next;
  }
}


struct test {
	int num;
	int book[100];

}a[26];
int main() {
	int n,i,j,index,temp,max;
	char s[100];
	char ch;
	scanf("%d",&n);
	for (i=0;i<26;i++) {
		a[i].num=0;
	}
	for (i=0;i<n;i++) {
		scanf("%d %s",&index,&s);
		for (j=0;s[j]!='\0';j++) {
			temp = (int)(s[j]-'A');
			a[temp].book[a[temp].num]=index;
			a[temp].num++;
		}
	}
	max = 0;
	for (i=0;i<26;i++) {
		if (a[i].num>a[max].num)
			max = i;

	}
  ch = (char)('A'+max);
		printf("%c\n",ch);
	printf("%d\n",a[max].num);
	for (i=0;i<a[max].num;i++) {
		printf("%d\n",a[max].book[i]);
	}

	return 0;
}


struct {
int num;
char w[26];

}book[999],test[1];

int main(int argc, char* argv[])
{
   int m,i,j,n,s;
   char x,c;
   scanf ("%d",&m);
   for (i=0;i<m;i++)
   {
   scanf ("%d%s",&book[i].num,book[i].w);

   }

   x='A';
   n=0;
   c='A';
   while (1)
   {
    s=0;
   for (i=0;i<m;i++)
   {
    for (j=0;j<strlen(book[i].w);j++)
	{
	 if (book[i].w[j]==x)
	 {s++;}

	}
   }

   if (s>n)
   {
   n=s;
   c=x;
   }
   if (x=='Z') {break;}
   x++;
   }
   printf ("%c\n%d\n",c,n);
   for (i=0;i<m;i++)
   {
    for (j=0;j<strlen(book[i].w);j++)
	{
	 if (book[i].w[j]==c)
	 {
		 printf ("%d\n",book[i].num);

	 }

	}
   }
	return 0;
}


void main()
{
struct books
{
int num;
char author[26];
}books[999];
int n,a[26]={0},max,i,j,u,lenth,temp;
scanf ("%d",&n);
for (i=0;i<n;i++)
scanf("%d %s",&books[i].num,books[i].author);
for (i=0;i<n;i++)
{
lenth=strlen(books[i].author);
for (j=0;j<lenth;j++)
{
for (u=0;u<26;u++)
{
if (books[i].author[j]=='A'+u)
a[u]++;
}
}
}
temp=a[0];
for (u=0;u<26;u++)
if (a[u]>=temp)
{
max=u;
temp=a[u];
}
printf ("%c\n%d\n",'A'+max,a[max]);
for (i=0;i<n;i++)
{
lenth=strlen(books[i].author);
for (j=0;j<lenth;j++)
{
if (books[i].author[j]=='A'+max)
printf("%d\n",books[i].num);
}
}
}


void main()
{
	struct b
	{
		int num;
		char str[27];
	}b[100];
	int n,i,m,j,max,nmax;
	int a[26]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %s",&b[i].num,b[i].str);
		m=strlen(b[i].str);
		for(j=0;j<m;j++)
		{
			a[b[i].str[j]-65]++;
		}
	}
	max=a[0];
	nmax=0;
	for(i=0;i<26;i++)
	{
		if(a[i]>max) {max=a[i];nmax=i;}
	}
	printf("%c\n%d\n",nmax+65,max);
	for(i=0;i<n;i++)
	{
		m=strlen(b[i].str);
		for(j=0;j<m;j++)
		{
			if(b[i].str[j]==nmax+65)
				printf("%d\n",b[i].num);
		}
	}
}


struct book
{
	int id;
	char peo[26];
}book1[999];
int main()
{
	int n,i,j,m=0,num[26]={0},length,max=0,t;
	char author;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%s",&book1[i].id,&book1[i].peo);
	}
	for(i=0;i<n;i++){
		length=strlen(book1[i].peo);
		for(j=0;j<length;j++){
			num[(int)(book1[i].peo[j]-'A')]++;
		}
	}
	for(i=0;i<26;i++){
		if(num[i]>max){
			max=num[i];
			t=i;
			author=i+'A';
		}
	}
	printf("%c\n%d\n",author,num[t]);
	for(i=0;i<n;i++){
		length=strlen(book1[i].peo);
		for(j=0;j<length;j++){
			if(book1[i].peo[j]==author){
				printf("%d\n",book1[i].id);
			}
		}
	}
	return 0;
}


struct x{
	int num;
	char author[26];
	int amount;
};
void main(){
	struct x y[999];
	int i,j,m,max=0,max_=0;
	int k;
	int amount[91]={0};
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %s",&y[i].num,y[i].author);
		y[i].amount=strlen(y[i].author);
	}
	for(i=0;i<m;i++){
		for(j=0;j<y[i].amount;j++){
			for(k='A';k<'Z';k++){
				if(k=y[i].author[j]){
					amount[k]++;
					break;
				}
			}
		}
	}
	for(i='A';i<'Z';i++){
		if(max<amount[i]){
			max=amount[i];
			max_=i;//ASCII??max_?????????
		}
	}
	printf("%c\n",max_);
	printf("%d\n",max);
	for(i=0;i<m;i++){
		for(j=0;j<y[i].amount;j++){
			if(y[i].author[j]==max_){
				printf("%d\n",y[i].num);
			}
		}
	}

}


int main()
{
	int n,d,i,j,l;
	struct a
	{
	    char name[27];
	    int c;
	}m[1000];
	struct b
	{
		int num,book[1000];
	    char t;
	};
    struct b author[27];
	for(i=1;i<=26;i++)
	{
	  author[i].t=i+64;
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
	  scanf("%d",&m[i].c);
	  scanf("%s",m[i].name);
	}
	for(i=1;i<=n;i++)
	{
		  l=strlen(m[i].name);
		for(j=0;j<=l-1;j++)
		{
		   d=m[i].name[j]-64;
		   author[d].num++;
		   author[d].book[author[d].num]=m[i].c;
		}
	}
	for(i=1;i<=25;i++)
	{
	   if(author[i].num>author[i+1].num)
		author[i+1]=author[i];
	}
	printf("%c\n",author[26].t);
	printf("%d\n",author[26].num);
	for(i=1;i<=author[26].num;i++)
	{
	  printf("%d\n",author[26].book[i]);
	}
	return 0;
}


int max(int array[26])
{
	int i,max=0;
	for(i=0;i<26;i++)
		if(array[i]>max)max=array[i];
	for(i=0;i<26;i++)
		if(max==array[i])break;
	return i;
}
void main()
{
	struct book
	{
		int num;
		char aut[26];
	};
	int a,i,j,m,k,t[26]={0};
	struct book nbook[999];
	scanf("%d",&m);
	for(i=0;i<m;i++)
		scanf("%d %s",&nbook[i].num,nbook[i].aut);
	for(i=0;i<m;i++)
		for(j=0;j<26;j++)
			for(k=0;k<26;k++)
				if(nbook[i].aut[j]==k+65)t[k]++;
	a=max(t);
	printf("%c\n%d\n",a+65,t[a]);
	for(i=0;i<m;i++)
		for(j=0;j<26;j++)
			if(nbook[i].aut[j]==a+65)printf("%d\n",nbook[i].num);
}


int main()
{
    int num[27] = {0};
    int n, i, j, temp;
    unsigned long len;
    char author[27], temp2, book[27][1000] = {'\0'};
    char str[4];
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> str;    //??????
        cin.get();
        cin.getline(author, 27);
        len = strlen(author);           //???unsigned long ?????????????
        for (j = 0; j < len; j++)
        {
            num[author[j] - 'A']++;
            strncat(book[author[j] - 'A'], str, 3);    //??????????????????
        }
    }
    temp = 0;
    for (j = 0; j < 26; j++)
    {
        if (num[j] > temp)
        {
            temp = num[j];
            temp2 = j + 'A';
        }
    }
    cout << temp2 << endl << temp << endl;
    for (j = 0; j < temp; j++)
    {
        for (i = 0; i < 3; i++)
            cout << book[temp2 - 'A'][j * 3 + i];    //??temp2 - 'A'??? temp?j*3 + i ??j + i
        cout << endl;
    }
    return 0;
}


int main()
{
    int n,i,j,l,x,maxnumber;
    scanf("%d",&n);
    int a[1000];
    char k[1000][30];
    int author[27]={0};
    for(i=1;i<=n;i++)
    {
		scanf("%d %s",&a[i],k[i]);
		int m;
		m=strlen(k[i]);
		for(j=0;k[i][j]!='\0';j++)
		{
			author[k[i][j]-'A'+1]++;
		}
    }
    int max=0;
    for(i=1;i<=26;i++)
    {
		if(author[i]>max)
		{
			max=author[i];
			maxnumber=i;
		}
    }
    char who;
    who='A'+maxnumber-1 ;
    printf("%c\n",who);
    printf("%d\n",max);
    for(i=1;i<=n;i++)
    {
                     for(l=0;l<=strlen(k[i]);l++)
                     if(k[i][l]==who)
                     printf("%d\n",a[i]);
    }
    return 0;
}


struct book
{
	int num;
	char aut[26];
};

int main()
{
	int i,j,k,m,x,a=0;
	int count[26]={0};
	char y;
	struct book all[1000];
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d%s",&all[i].num,&all[i].aut);
	}
	for(i=0;i<m;i++){
		for(j=0;j<26;j++){
			if(all[i].aut[j]>='A'&&all[i].aut[j]<='Z'){
				x=(int)(all[i].aut[j]-'A');
				count[x]++;
			}
		}
	}
	for(i=0;i<26;i++){
		if(count[i]>a){
			a=count[i];
			k=i;
		}
	}
	y=k+'A';
	printf("%c\n%d\n",y,a);
	for(i=0;i<m;i++){
		for(j=0;j<26;j++){
			if(all[i].aut[j]==y){
				printf("%d\n",all[i].num);
				break;
			}
		}
	}
	return 0;
}


main()
{
      int amount_temp=0,amount_most=0;
      char most,temp;
      int i,j,k,s,p;
      int m;
      char jiancha[27];
      struct xinxi
      {
             int bianhao;
             char zuozhe[27];
      };
      struct xinxi shuru[999];
      scanf("%d",&m);
      for(p=0;p<m;p++)
      {
          scanf("%d %s",&shuru[p].bianhao,shuru[p].zuozhe);
      }
      for(temp='A';temp<='Z';temp++)
      {
          for(i=0;i<m;i++)
          {
              strcpy(jiancha,shuru[i].zuozhe);
              for(j=0;j<strlen(jiancha);j++)
              {
                  if(jiancha[j]==temp)
                  {
                      amount_temp++;
                  }
              }
          }
          if(amount_temp>amount_most)
          {
              amount_most=amount_temp;
              most=temp;
              amount_temp=0;
          }
          else
          {
              amount_temp=0;
          }
      }
      printf("%c\n%d\n",most,amount_most);
      for(i=0;i<m;i++)
          {
              strcpy(jiancha,shuru[i].zuozhe);
              for(j=0;j<strlen(jiancha);j++)
              {
                  if(jiancha[j]==most)
                  {
                      printf("%d\n",shuru[i].bianhao);
                      break;
                  }
              }
          }
}


int a[26]={0} ;int n;int max;int hao;
struct chushu
{
    int num;
    char s[30];
    struct chushu *next;
};
struct chushu *create()
{
    int j=0,q,i=0,k=0;

    struct chushu *head,*p1,*p2;
    p1=(struct chushu *)malloc(len);
    scanf("%d %s",&p1->num,p1->s);

    for (i=0;p1->s[i]!='\0';i++)
    {
        j=p1->s[i]-65;
        a[j]=a[j]+1;
    }

    head=p1;p2=p1;
    while(k<n-1)
    {
    	k++;
        p2=p1;
        p1=(struct chushu *)malloc(len);
        scanf("%d %s",&p1->num,p1->s);

        for (i=0;p1->s[i]!='\0';i++)
        {
            j=p1->s[i]-65;
            a[j]=a[j]+1;
        }

        p2->next=p1;

    }
    p2=p1;
    p2->next=NULL;
    return (head);
}

/*void print(struct chushu *head)
{
    struct chushu *p;
    p=head;
	while(p!=NULL)
	{printf("%d\n",p->num);
	p=p->next;}
}*/

void search(struct chushu *head)
{
    int i;
    struct chushu *p;
    p=head;
    while (p->next!=NULL)
    {
    	for (i=0;p->s[i]!='\0';i++)
    	{
    	    if (hao+65==p->s[i])
    	    printf("%d\n",p->num);
    	}
    	p=p->next;
    }
    for (i=0;p->s[i]!='\0';i++)
    	{
    	    if (hao+65==p->s[i])
    	    printf("%d\n",p->num);
    	}
}

void main()
{
    int i;
    struct chushu *p;

    scanf("%d",&n);
    p=create();
    max=0;
    //print(p);

  for (i=0;i<26;i++)
    {
    	if (a[i]>max)
    	{
    	    max=a[i];
    	    hao=i;
    	}
    }
    printf("%c\n",hao+65);
    printf("%d\n",max);
    search(p);
}


struct info
{
	int num;
	char author[26];
} a[1000];

int main()
{
	int i,m,j,b[26]={0};
	char out;
	scanf("%d\n",&m);
	for(i=0;i<m;i++)
	scanf("%d %s\n",&a[i].num,a[i].author);
	for(i=0;i<m;i++)
		for(j=0;j<26;j++)
			b[a[i].author[j]-'A']++;
	int max=b[0];
	for(i=0;i<26;i++)
		max=max>b[i]?max:b[i];
	for(i=0;i<26;i++)
		if(b[i]==max)
		{
			out='A'+i;
			printf("%c\n",'A'+i);
			printf("%d\n",b[i]);
			break;
		}
	for(i=0;i<m;i++)
		for(j=0;j<26;j++)
			if(a[i].author[j]==out)
			{
				printf("%d\n",a[i].num);
				break;
			}
}


int main()
{
	int n,book[1000],cnt[60],max;
	char author[1000][26],p;
	int b[60][1000];
	cin>>n;
	for(int i=0;i<60;i++)
		cnt[i]=0;
	for(int i=0;i<n;i++)
	{
		cin>>book[i];
	    cin.get();
	    cin.getline(author[i],26);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;author[i][j]!='\0';j++)
			{
				int k=author[i][j]-'0';
				b[k][cnt[k]++]=book[i];//?i???K????
		    }

	}
	max=cnt[17];
	p='A';
	for(int i=17;i<=42;i++)
	{
		if(cnt[i]>max)
			{
				max=cnt[i];
				p=i+'0';
		}
	}
	cout<<p<<endl;
	cout<<max<<endl;
	for(int m=0;m<max;m++)
	cout<<b[p-'0'][m]<<endl;
	return 0;
}


int main()
{
	int m,i,j;
	scanf("%d",&m);

	struct Bookinfo
	{
		int number;
		char auther[27];
	};

	struct Bookinfo a[1000];
	for (i=0;i<m;i++)
		scanf("%d %s",&a[i].number,a[i].auther);

	int count[26]={0},max,record;

	for (i=0;i<m;i++)
	{
		int k;
		k=strlen(a[i].auther);
		for (j=0;j<k;j++)
		{
			count[a[i].auther[j]-'A']++;
		}
	}

	max=count[0];
	for (i=0;i<26;i++)
		if (count[i]>=max)
		{
			max=count[i];
			record=i;
		}

	printf("%c\n%d\n",record+'A',max);

	for (i=0;i<m;i++)
	{
		int n;
		n=strlen(a[i].auther);
		for (j=0;j<n;j++)
			if (a[i].auther[j]==record+'A')
			{
				printf("%d\n",a[i].number);
				break;
			}
	}
}


int main()
{
	int n,amount[26],num[26][1000],num0,max=0;
	char a;
	memset(amount,0,sizeof(amount));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>num0;
		cin.get();
		a=cin.get();
		while(a!='\n')
		{
			num[a-65][amount[a-65]]=num0;
			amount[a-65]++;
			a=cin.get();
		}
	}
	for(int i=0;i<26;i++)
		if(max<amount[i])
			max=amount[i];
	for(int i=0;i<26;i++)
		if(max==amount[i])
		{
			a=i+65;
			cout<<a<<endl<<max<<endl;
			for(int j=0;j<max;j++)
				cout<<num[i][j]<<endl;
			break;
		}
	return 0;
}


void main()
{
     struct book
     {
            int num;
            char name[26];
     };
     int m,i,j,max;
     int sum[26]={0};
     scanf("%d",&m);
     struct book b[m];
     for(i=0;i<m;i++)
       scanf("%d %s",&b[i].num,b[i].name);
     for(i=0;i<m;i++)
     {
                     for(j=0;j<strlen(b[i].name);j++)
                         sum[(b[i].name)[j]-'A']++;

     }
     max=0;
     for(i=1;i<26;i++)
       if(sum[i]>sum[max])max=i;
     printf("%c\n%d\n",max+'A',sum[max]);
     for(i=0;i<m;i++)
     {
                     for(j=0;j<strlen(b[i].name);j++)
                     {
                        if((b[i].name)[j]==65+max)
                        printf("%d\n",b[i].num);
                        }
     }

}


int main()
{
    int n,i,l,x,maxnumber;
    scanf("%d",&n);
    int a[1000];
    char k[1000][30];
    int author[27]={0};
    for(i=1;i<=n;i++)
    {
                      scanf("%d %s",&a[i],k[i]);
                      int m;
                      m=strlen(k[i]);
                      for(l=0;l<30;l++)
                      {
                                        for(x=1;x<=26;x++)
                                        {
                                                          if(k[i][l]==x+64)
                                                          author[x]++;
                                        }
                      }
    }
    int max=0;
    for(i=1;i<=26;i++)
    {
                      if(author[i]>max)
                      max=author[i];
    }
    for(i=1;i<=26;i++)
    {
                      if(author[i]==max)
                      maxnumber=i;
    }
    char who[10];
    who[0]='A'+maxnumber-1 ;
    printf("%c\n",who[0]);
    printf("%d\n",max);
    for(i=1;i<=n;i++)
    {
                     for(l=0;l<=strlen(k[i]);l++)
                     if(k[i][l]==who[0])
                     printf("%d\n",a[i]);
    }
    return 0;
}


struct book
{
 int a;
 char b[30];
 struct book *next;
};
void main()
{
 int i,k,m,max=0,t;
 char j,ch;
 struct book *head,*p1,*p2;
 scanf("%d",&m);
 p1=(struct book*)calloc(1,sizeof(struct book));
 head=p1;
 for(i=0;i<m;i++)
 {
  scanf("%d %s",&(p1->a),p1->b);
  p2=p1;
  if(i==m-1)
   p2->next=NULL;
  else
  {
   p1=(struct book*)calloc(1,sizeof(struct book));
   p2->next=p1;
  }
 }
 for(j='A';j<='Z';j++)
 {
 t=0;
 p1=head;
 while(p1)
 {
  for(k=0;k<strlen(p1->b);k++)
   if((p1->b)[k]==j)
	t++;
  p1=p1->next;
 }
 if(t>max)
 {
  max=t;
  ch=j;
 }
 }
 printf("%c\n",ch);
 printf("%d\n",max);
 p1=head;
 while(p1)
 {
  for(k=0;k<strlen(p1->b);k++)
   if((p1->b)[k]==ch)
	printf("%d\n",p1->a);
  p1=p1->next;
 }
}


struct books{
	int num;
	char writer[26];
	struct books *next;
};

int m;

struct books *creat()
{
	struct books *head,*p1,*p2;
	int i;
	p2=p1=(struct books*)malloc(sizeof(struct books));
	for (i=1;i<=m;i++){
		if (i==1) head=p1;
		scanf("%d %s",&p1->num,p1->writer);
		p2=p1;
		if(i!=m){
			p1=(struct books*)malloc(sizeof(struct books));
			p2->next=p1;
		}
		else p2->next=NULL;
	}
	return head;
}

void main()
{
	int character[26];
	struct books *head,*p;
	int i,max=0,imax;
	for (i=0;i<26;i++) character[i]=0;
	scanf("%d",&m);
	head=creat();
	p=head;
	while(1){
		i=0;
		while(*(p->writer+i)){
			character[*(p->writer+i)-'A']++;
			i++;
		}
		p=p->next;
		if(p==NULL) break;
	}

	for (i=0;i<26;i++){
		if (character[i]>max){
			max=character[i];
			imax=i;
		}
	}

	printf("%c\n%d\n",imax+'A',max);

	p=head;
	while(1){
		i=0;
		while(*(p->writer+i)){
			if(*(p->writer+i)==imax+'A'){
				printf("%d\n",p->num);
				break;
			}
			i++;
		}
		p=p->next;
		if(p==NULL) break;
	}
}


struct book{
	int num;
	char s[27];
}shu[1000];
int main(){
	int n,i,l,j,max;
	char name;
	int letter[26]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%s",&shu[i].num,&shu[i].s);
		l=strlen(shu[i].s);
		for(j=0;j<l;j++){
			letter[(shu[i].s[j]-65)]++;
		}
	}
	for(max=letter[0],name=65,i=1;i<26;i++){
		if(letter[i]>max){
			max=letter[i];
			name=i+65;
		}
	}
	printf("%c\n%d\n",name,max);
	for(i=0;i<n;i++){
		l=strlen(shu[i].s);
		for(j=0;j<l;j++){
			if(shu[i].s[j]==name){
				printf("%d\n",shu[i].num);
			}
		}
	}
	return 0;
}


 struct author
 { int num;
   char name[26];

 };
 struct author ren[100];

 int main()
 { int n,i,j=0,k=0,biao,maxzuozhe,p,geshu[26]={0},max=0,maxdeshu[999];

   scanf("%d\n",&n);
   for(i=0;i<=n-1;i++)
   { scanf("%d",&ren[i].num);
    scanf("%s",ren[i].name);
   }

   for(i=0;i<=25;i++)
   { for(j=0;j<=n-1;j++)
      {
            for(k=0;k<=strlen(ren[j].name);k++)
            { if((i+'A')==ren[j].name[k])
              geshu[i]=geshu[i]+1;
              }
      }
    }
       for(i='A'-65;i<='Z'-65;i++)
   { if(max<geshu[i])
     {max=geshu[i];
      biao=i;}
    }
    maxzuozhe='A'+biao;
    p=0;
    for(i=0;i<=n-1;i++)
    { for(k=0;k<=strlen(ren[i].name);k++)
      { if(maxzuozhe==ren[i].name[k])
        {maxdeshu[p]=ren[i].num;
         p++;
         break;}
      }
    }
    printf("%c\n",maxzuozhe);
    printf("%d\n",p);
    for(i=0;i<=p-1;i++)
    printf("%d\n",maxdeshu[i]);

    getchar();

}


int main()
{
	int n,book[1000],i,j,countt[26]={0},len,max=-1, maxauthor;
	char peo[1000][27],sum[100000]="\0",ch;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> book[i] >> peo[i];
		strcat(sum,peo[i]);
	}
	len=strlen(sum);
	for(i=0;i<len;i++)
		countt[sum[i]-65]++;
	for(i=0;i<26;i++)
		if(countt[i]>max)
		{
			max=countt[i];
			maxauthor = i;
		}

	ch=maxauthor+65;
	int p=0,t=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<strlen(peo[i]);j++)
			if(peo[i][j]==ch)
				p++;
		if(p>0)
			book[i-t]=book[i];
		else
			t++;
		p=0;
	}
	cout << ch << endl;
	cout << n-t << endl;
	for(i=1;i<=n-t;i++)
		cout << book[i] << endl;
	return 0;
}


struct{
	int location[1001];
	int num;
	int sum;
}ans[27];
int main()
{
	int n,value=-1,order,m;
	char s[28];
	cin>>n;
	for(int i=1;i<=26;i++)
	{
		ans[i].num=ans[i].sum=0;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		cin>>s;
		for(int j=0;j<strlen(s);j++)
		{
			ans[s[j]-'A'+1].num++;
			ans[s[j]-'A'+1].sum++;
			ans[s[j]-'A'+1].location[ans[s[j]-'A'+1].num]=m;
		}
	}
	for(int i=1;i<=26;i++)
	if(ans[i].sum>value)
	{
		value=ans[i].sum;
		order=i;
	}
	cout<<(char)(order+'A'-1)<<endl;
	cout<<ans[order].num<<endl;
	for(int i=1;i<=ans[order].num;i++)
		cout<<ans[order].location[i]<<endl;
		return 0;
}


struct sa
{
	int a;
	char b[100];
	struct sa *next;
};
int n,m,k[27];
struct sa *kao(void)
{
	struct sa *head;
	struct sa *p1,*p2;
	n=0;
    head=NULL;
	p1=p2=(struct sa *)malloc(len);
	scanf("%d %s",&p1->a,p1->b);
	head=p1;
    for(;;)
	{
       n++;
	   if(n==m+1)
		   break;
	   if(n==1)
		   head=p1;
	   else
	   {
		   p2=p1;
           p1=(struct sa *)malloc(len);
		   scanf("%d %s",&p1->a,p1->b);
		   p2->next=p1;
	   }
	}
	p1->next=NULL;
	return (head);
}
int main()
{
	struct sa *p,*q,*head,*ped;
	int f,i,g,s=1,t,d=0;
	char c;
	scanf("%d",&m);
	head=kao();
	for(p=head;p!=NULL;p=p->next)
	{
        g=strlen(p->b);
		for(i=0;i<g;i++)
		{
			k[p->b[i]-64]++;
		}
	}
	t=k[1];
	for(i=2;i<27;i++)
	{
		if(k[i]>k[s])
		{s=i;t=k[i];}
	}
	printf("%c\n%d\n",s+64,t);
	for(p=head;p!=NULL;)
	{
		g=strlen(p->b);
		for(i=0;i<g;i++)
		{
			if(p->b[i]==s+64)
			{
				d=1;break;
			}
		}
		if(d==1)
			printf("%d\n",p->a);
		d=0;
		p=p->next;
	}
	return 0;
}


void main()
{
	struct book
	{
		int num;
		char auth[26];
		int inf[26];
		struct book *next;
	};
	struct book *head,*p1,*p2,*t1,*t2;
	head=(struct book *)malloc(sizeof(struct book));

	int m,i,k,l,j,max;
	int authnum[26]={0};
	scanf("%d",&m);
	p1=head;
	p2=p1;
	for (i=0;i<(m-1);i++)
	{
		scanf("%d %s",&(p1->num),p1->auth);
		p2=(struct book *)malloc(sizeof(struct book));
		p1->next=p2;
		p1=p2;
	}
	scanf("%d %s",&(p1->num),p1->auth);
	p2=NULL;
	p1->next=p2;

	p1=head;
	p2=p1;
	while(p1!=NULL)
	{
		l=strlen(p1->auth);
		for(j=0;j<l;j++)
		{
			p1->inf[(*((p1->auth)+j))-65]=1;
			authnum[(*((p1->auth)+j))-65]++;
		}
		p2=p1->next;
		p1=p2;
	}
	max=0;
	for(i=1;i<26;i++)
	{
		if (authnum[i]>authnum[max]) max=i;
	}
	printf("%c\n",(max+65));
	printf("%d\n",authnum[max]);

	p1=head;
	p2=p1;
	while(p1!=NULL)
	{
		if ((p1->inf[max])>0)
			printf("%d\n",p1->num);
		p2=p1->next;
		p1=p2;
	}
	p1=head;
	p2=p1;
	while(p1!=NULL)
	{
		p2=p1->next;
		free(p1);
		p1=p2;
	}
}


struct book{
	int name;
	char writer[100];
	struct book *next;
};

int a[26];

struct book *creat(int n)
{
	struct book *p1,*p2,*xhead;
	p1=(struct book*)malloc(len);
	scanf("%d %s",&p1->name,p1->writer);
	p2=p1;
	xhead=p1;

	while(n-1)
	{
		n--;
		p1=(struct book *)malloc(len);
		scanf("%d %s",&p1->name,p1->writer);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return xhead;
}

void find(struct book*head)
{
	struct book *p;
	int i;
	char s[100];
	p=head;
	while(p)
	{
		i=0;
		strcpy(s,p->writer);
		while(s[i]!='\0')
		{a[s[i]-'A']++;
		    i++;
		}

		p=p->next;
	}
}

void print(struct book *head,int max)
{
	struct book *p;
	p=head;
	while(p)
	{
		if(strchr(p->writer,max+'A')) printf("%d\n",p->name);
		p=p->next;
	}
}

void main()
{
	int i,max=0,n;
	struct book *head;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	head=creat(n);
	find (head);
	for(i=0;i<26;i++)
		if(a[i]>a[max]) max=i;
	printf("%c\n",max+'A');
	printf("%d\n",a[max]);
	print(head,max);
}


int main ()
{
    int m;
    cin >> m;
    char writter[27];
    int data[26][1000];
    memset(data,0,sizeof(data));
    int max = 0;
    char max_name;
    for (int i = 1; i <= m; i++){
        int number;
        cin >> number >> writter;
        for (int j = 0; j < strlen(writter); j++){
            data[writter[j]-65][0]++;
            data[writter[j]-65][data[writter[j]-65][0]] = number;
            if (max < data[writter[j]-65][0]){
                max = data[writter[j]-65][0];
                max_name = writter[j];
            }
        }
    }
    cout << max_name << endl << max << endl;
    for (int i = 1; i <= max; i++)
        cout << data[max_name - 65][i] << endl;
    return 0;
}