#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int max=0,k,l,i;
char a[1020];
int b[27]={0};
scanf("%s",a);
l=strlen(a);
for(i=0;i<l;i++)
b[a[i]-'a']++;
for(i=0;i<26;i++)
if(b[i]>max)
{
max=b[i];
k=i;
}
printf("%c
",k+'a');
}
return 0;
}