#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void) {
	long double max=0, t, log26=1.4149733;
	int c, n, i, j, l;
	char str[1001], maxS[1001];
	scanf("%d",&c);
	while(c--){
		scanf("%d",&n);
		max=1;
		for(i=0;i<n;i++){
			scanf("%s",str);
			t=0;
			l=strlen(str);
			if(l*log26<max) continue;
			for(j=0;j<l;j++){
				if(str[j] > 65) t+=log26;
				else t++;
			}
			if(max<t){
				max = t;
				memcpy(maxS, str, strlen(str)+1);
			} else if(max==t){
				for(j=0;j<strlen(str);j++){
					if(str[j] < maxS[j]) {
						memcpy(maxS, str, strlen(str)+1);
						break;
					} else if(str[j]>maxS[j]) break;
				}
			}
		}
		printf("%s\n", maxS);
	}
	return 0;
}