```cpp
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int main(){
string s;
int sum,max;
int n,lens;
cin>>n;
for(int i=0;i<n;i++){
cin>>s;
char maxs=s[0];//每次赋初值
lens=s.size();
sum=1,max=1;//外循环每次刷新初值
for(int j=0;j<lens;j++){
if(s[j]==s[j+1]){
sum++;
if(sum>max){
max=sum;
maxs=s[j];
}
}
else sum=1;
}
cout<<maxs<<' '<<max<<endl;
}
return 0;
}