#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	return *(int*)b - *(int*)a;
}
int main()
{
	int n;
	int i, j;
	int count[30];
	int a[30];
	char c[102];
	int x;
	int max;
	for (;;)
	{
		scanf("%d", &n);
		if (n == 0)
			return 0;
		for (i = 0; i < n; i++)
		{
			scanf("%c", &c[i]);
			if (c[i]<'A' || c[i]>'Z')
				i--;
		}
		for (i = 0; i < 30; i++)
			count[i] = 0;
		for (i = 0; i < n; i++)
		{
			x = 0;
			count[c[i] - 'A']++;
			for (j = 0; j < 30; j++)
				a[j] = count[j];
			qsort(a, 30, sizeof(int), asc);
			if (a[0] > a[1] + n - i - 1)
			{
				int max = 0;
				for (j = 0; j < 30; j++)
					if (count[max] < count[j])
						max = j;
				printf("%c %d\n", 'A' + max, i + 1);
				x++;
				break;
			}
		}
		if (x == 0)
			printf("TIE\n");
	}
}
