// Aizu 1609: Look for the Winner!
// 2017.9.21 bal4u@uu

#include <stdio.h>
#include <string.h>

int f[30];
int c[102];

int main()
{
	int n, x, i, k, x1, x2, max1, max2;
	char b[5];

	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) scanf("%s", b), c[i] = *b - 'A'; 
		memset(f, 0, sizeof(f));
		max1 = max2 = 0, x1 = x2 = -1;
		for (k = n, i = 0; i < n; ) {
			x = c[i], i++, k--;
			f[x]++;
			if (f[x] > max1) {
				if (x1 < 0 || x == x1) max1 = f[x], x1 = x;
				else max2 = max1, x2 = x1, max1 = f[x], x1 = x;
			} else if (f[x] > max2) max2 = f[x]; x2 = x;
			if (max2 + k < max1) break;
		}
		if (max1 == max2) puts("TIE");
		else printf("%c %d\n", x1+'A', i);
	}
	return 0;
}