#include<iostream>
#include<queue>
using namespace std;
typedef pair<pair<int, int>, char> p;
int main() {
	int n; 
	while (cin >> n, n) {
		priority_queue<p>pq;
		for (int i = 0; i < n; i++) {
			p p1;
			cin >> p1.second;
			p1.first.first = 0;
			p1.first.second = n;
			for (int j = 1; j < n; j++) {
				int k; cin >> k;
				if (!k)p1.first.first++;
				else if (k == 1)p1.first.second--;
			}
			pq.push(p1);
		}
		for (int i = 0; i < n; i++) {
			cout << pq.top().second << endl;
			pq.pop();
		}
	}
	return 0;
}
