#include <stdio.h>


int main(void){
	int num, sum[30], first, second;
	char ch[101];

	while(1){
		scanf("%d", &num);
		if(num == 0) break;
		for(int i=0; i<num; i++){
			scanf(" %c", &ch[i]);
			ch[i] -= 'A';
		}

        for(int i=0; i<30; i++){
            sum[i] = 0;
        }
		first = ch[0];
		second = 29;
		for(int i=0; i<num; i++){
			sum[ch[i]]++;
			if(sum[ch[i]] > sum[first]){
				second = first;
				first = ch[i];
			} else if(sum[second] < sum[ch[i]] && ch[i] != first){
				second = ch[i];
			}
			if(sum[first] > sum[second] + num - i - 1){
				printf("%c %d\n", first+'A', i+1);
				goto END;
			}
		}
		printf("TIE\n");
END:;
	}//endwhile

	return 0;
}
