// Verdict :: Accepted
/// Header file begin
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include<utility>
#include <queue>
#include <algorithm>
/// End
//..........
/// Macro
#define sf scanf
#define pf printf
#define sfint(a,b) scanf("%d %d",&a,&b)
#define sfl(a,b) scanf("%ld %ld",&a,&b)
#define sfll(a,b) scanf("%lld %lld",&a,&b)
#define sfd(a,b) scanf("%lf %lf",&a,&b)
#define sff(a,b) scanf("%f %f",&a,&b)
#define lp1(i,n) for(i=0;i<n;i++)
#define lp2(i,n) for(i=1;i<=n;i++)
#define mem(c,v) memset(c,v,sizeof(c))
#define cp(a) cout<<" "<<a<<" "<<endl
#define nl puts("")
#define sq(x) ((x)*(x))
#define all(x) x.begin(),x.end()
#define reall(x) x.rbegin(),x.rend()
#define sz size()
#define gc getchar()
#define pb push_back
/// End.........
/// Size
#define mx7 20000100
#define mx6 1500000
#define mx5 100005
#define mx4 1000100
#define inf 1<<30 //infinity value
#define eps 1e-9
#define mx (65540)
#define mod 1000000007
#define pi acos(-1.0)
/// Macros for Graph
#define white 0
#define gray 1
#define black -1
#define nil -2
using namespace std;
//..................................................................................................................
typedef long long LL;
typedef long L;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int, int> pii;
map<int,int>mpii;
map<char,int>mpc;
map<string,int>mpsi;
map<bool,int>mpbi;
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T large(T a, T b ) {return a>b?a:b;}
template<class T> T small(T a, T b ) {return a<b?a:b;}
template<class T> T diffrnce(T a, T b) {return a-b<0?b-a:a-b;}
struct my
{
int freq;
char ch;
};
bool cmp(my a, my b)
{
return a.freq > b.freq;
}
int main()
{
int t;
my ar[200+5];
vector<char>vch;
sf("%d\n",&t);
while(t--)
{
string s;
getline(cin,s);
int len=s.size(),arlen=0;
vch.clear();
mpc.clear();
for(int i=0;i<len;i++)
{
if(s[i]>='A' and s[i]<='Z')
{
s[i] = (char) (s[i]+32);
}
if(s[i]==' ')
{
continue;
}
else
{
mpc[s[i]]++;
ar[arlen].freq=mpc[s[i]];
ar[arlen++].ch=s[i];
}
}
sort(ar,ar+arlen,cmp);
// for(int i=0;i<arlen;i++)
// {
// pf("%c-%d ",ar[i].ch,ar[i].freq);
// }
int maxi=ar[0].freq;
for(int i=0;i<arlen;i++)
{
if(maxi == ar[i].freq)
{
vch.push_back(ar[i].ch);
}
else
{
//vch.push_back(ar[i].ch);
break;
}
}
sort(all(vch));
int vlen=vch.size();
for(int i=0;i<vlen;i++)
{
pf("%c",vch[i]);
}
nl;
}
return 0;
}
/*
Computers account for only 5% of the country's commercial electricity consumption.
output : co
Computers account for only.
output : o */
Comments
Post a Comment