#include<iostream>
using namespace std;
int main()
{
	int n,score;
	int tokuten[10];
	char name[10];
	while(1){
		for(int i=0;i<10;i++)
			tokuten[i] = 0;
		cin >> n;
		if(n == 0)
			break;
		for(int i=0;i<n;i++){
			cin >> name[i];
			for(int j=0;j<n-1;j++){
				cin >> score;
				if(score ==0)
					tokuten[i] += 100;
				else if(score == 1)
					tokuten[i]--;
			}
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(tokuten[i] < tokuten[j]){
					int T = tokuten[i];
					tokuten[i] = tokuten[j];
					tokuten[j] = T;
					char TT = name[i];
					name[i] = name[j];
					name[j] = TT;
				}
			}
		}
		for(int i=0;i<n;i++)
			cout << name[i] << endl;
	}
	return 0;
}