#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pair<int,string> > team(10);

int main() {
	int n;
	int score;
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			team[i].first=0;
			cin>>team[i].second;
//cout<<team[i].second<<endl;
			int j;
			for(j=0;j<n-1;j++){
				score=in();
				if(score==0)team[i].first+=100;
				if(score==2)team[i].first++;
//cout<<" "<<score<<endl;
			}
//cout<<team[i].second<<" "<<team[i].first<<endl;
		}
		int a,b;
		for(a=0;a<n;a++){
			for(b=0;b<n-1;b++){
				if(team[b].first<team[b+1].first){
					pair<int,string> buf;
					buf=team[b];
					team[b]=team[b+1];
					team[b+1]=buf;
				}
			}
		}
		for(i=0;i<n;i++){
			cout<<team[i].second<<endl;
		}
	}
	return 0;
}