#include <iostream>
using namespace std;

char teamname[10];
int team[10];

void init()
{
	for(int i=0;i<10;i++){
		teamname[i] = NULL;
		team[i] = 0;
	}
}
int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		init();
		int match;
		for(int i=0;i<n;i++){
			cin >> teamname[i];
			for(int j=0;j<n-1;j++){
				cin >> match;
				switch(match){
					case 0:
						team[i]+=10;
						break;
					case 1:
						team[i]-=1;
						break;
					default:
						break;
				}
			}
		}
		for(int j=0;j<n-1;j++){
			for(int i=0;i<n-1-j;i++){
				if(team[i] < team[i+1]){
					int tmp=team[i+1];char tempp = teamname[i+1];
					team[i+1] = team[i];teamname[i+1] = teamname[i];
					team[i] = tmp;teamname[i] = tempp;
				}
			}
		}
		for(int i=0;i<n;i++){
			cout << teamname[i]<< endl;
		}
	}
	return 0;
}