/*
 * Copyright (C) 2016 Hiroyasu Kamo
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * ACM-ICPC 2016 Japan Domestic Contest
 *  Problem B  Look for the Winner!
 *
 *	Author: Hiroyasu Kamo <wd@ics.nara-wu.ac.jp>
 */

#include <utility>
#include <string>
#include <vector>
#include <map>
#include <iostream>
using std::move;
using std::pair;
using std::make_pair;
using std::swap;
using std::string;
using std::map;
using std::vector;
using std::cin;
using std::cout;

const pair<string, int>
get_winner(const vector<string> &votes)
{
	int	num_rest = votes.size();
	string	leader = "";
	int	num0 = 0, num1 = 0;
	map<string, int>	nums;
	for (auto p = votes.begin(); p != votes.end(); ++ p) {
		-- num_rest;
		const int	num_new = ++ nums[*p];
		if (leader != *p) {
			if (num1 < num_new) {
				num1 = num_new;
			}
			if (num0 < num1) {
				swap(num0, num1);
				leader = *p;
			}
		} else {
			num0 = num_new;
		}
		if (num0 > num1 + num_rest)
			return make_pair(leader, votes.size() - num_rest);
	}
	return make_pair("", 0);
}

int
main()
{
	for (int n; cin >> n && n > 0; ) {
		vector<string>	votes;
		for (int i = 0; i < n; ++ i) {
			string	c;
			cin >> c;
			votes.push_back(move(c));
		}
		const pair<string, int>	w = get_winner(votes);
		if (w.second > 0) {
			cout << w.first << " " << w.second;
		} else {
			cout << "TIE";
		}
		cout << std::endl;
	}
	return 0;
}
