#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
#define P pair<int,int>
using namespace std;

int main() {
	int a;
	while (cin >> a, a) {
		char t[100];
		for (int i = 0; i < a; i++)cin >> t[i];
		int b[26]{};
		for (int c = 0; c < a; c++) {
			char d = t[c];
			b[d - 'A']++;
			P e[26];
			for (int f = 0; f < 26; f++) {
				e[f] = P(b[f], f);
			}
			sort(e, e + 26, greater<P>());
			if (e[0].first > e[1].first + a - c - 1) {
				cout << char(e[0].second+'A')<<" "<<c+1 << endl;
				goto l;
			}
		}
		puts("TIE");
	l:;
	}
}