#include <bits/stdc++.h>
using namespace std;

enum {WIN, LOSE, DRAW};

int main() {
	for(int n; cin >> n && n;) {
		vector<pair<int, int>> ranking; // score, ID
		vector<char> names(n);

		for(int i = 0; i < n; ++i) {
			cin >> names[i];

			int score = 0;
			for(int j = 0; j < n - 1; ++j) {
				int result;
				cin >> result;

				switch(result) {
				case WIN:
					score += 100;
					break;
				case LOSE:
					break;
				case DRAW:
					score += 1;
					break;
				default:
					assert(false);
				}
			}

			ranking.emplace_back(-score, i);
		}

		sort(ranking.begin(), ranking.end());

		for(const auto &team : ranking) {
			cout << names[team.second] << endl;
		}
	}

	return EXIT_SUCCESS;
}