#include "bits/stdc++.h"
using namespace std;
struct result{
	char name;
	int win;
	int draw;
	int id;
};
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		pair<int, int>amax(-1, -1);
		vector<result>res;
		for (int i = 0; i < N; ++i) {
			char c; cin >> c;
			pair<int, int>score;
			for (int j = 0; j < N - 1; ++j) {
				int a; cin >> a;
				if (a == 0)score.first++;
				else if (a == 2)score.second++;
			}
			res.push_back(result{ c,score.first,score.second,i });

		}
		sort(res.begin(), res.end(), [](const result&l, const result&r) {
			return l.win == r.win ? l.draw == r.draw ? l.id<r.id : l.draw>r.draw : l.win>r.win;
		});
		for (auto r : res) {
			cout << r.name << endl;
		}
	}
	
	return 0;
}