#include <stdio.h>

int main(void) {
	int n;
	char c[100][4];
	int i, j;
	while (scanf("%d", &n) == 1 && n > 0) {
		int hyou[27] = {0}; /* 26 letters + one more candidate */
		int won = 0;
		for (i = 0; i < n; i++) {
			if (scanf("%s", c[i]) != 1) return 1;
		}
		for (i = 0; i < n; i++) {
			int left = n - i - 1;
			int max = 0, max_index = 0, second_max = 0;
			hyou[c[i][0] - 'A']++;
			for (j = 0; j < 27; j++) {
				if (hyou[j] >= max) {
					second_max = max;
					max = hyou[j];
					max_index = j;
				} else if (hyou[j] >= second_max) {
					second_max = hyou[j];
				}
			}
			if (max > second_max + left) {
				printf("%c %d\n", max_index + 'A', i + 1);
				won = 1;
				break;
			}
		}
		if (!won) puts("TIE");
	}
	return 0;
}