cpp code
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
while(n -- ){
string str, maxs;
int maxn = -1;
cin >> str;
for(int i = 0; i < str.size(); i ++ ){
int j = i;
int cnt = 0;
while(str[j] == str[i] && j < str.size())
j ++ , cnt ++ ;
if(cnt > maxn) maxn = cnt, maxs = str[i];
i = j - 1;
}
cout << maxs << ' ' << maxn << endl;
}
return 0;
}