#include<iostream>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;

int main() {
	int n;
	while (true) {
		cin >> n; if (n == 0)break;
		char name;
		double w, f;
		priority_queue<pair<double,char>> results;
		for (int i = 0; i < n;++i) {
			cin >> name;
			w = 0.0, f = 0.0;
			for (int j = 0; j < n - 1; ++j) {
				double r;
				cin >> r;
				if (r == 0)++w;
				if (r == 1)++f;
			}
			f *= 0.00000000000001;
			double result = w - f;
			results.push(make_pair(result,name));
		}
		while(!results.empty()) {
			cout << results.top().second << endl;
			results.pop();
		}
	}
	return 0;
}