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

class Team{
public:
	int x,y,z;
	Team(){ x=y=z=0;}
	Team(int win, int loose, int ID){ x=win, y=loose, z=ID;}
	bool operator>(Team tmp){
		if( this->x > tmp.x ) return true; else if( this->x < tmp.x ) return false;
		// winが等しい
		if( this->y < tmp.y ) return true; else if( this->y > tmp.y ) return false;
		//勝ちも負けも等しい
		return this->z < tmp.z;
	}
};
bool cmp(Team a, Team b){
	return a > b;
}
int main() {
	while(1){
		int n; cin >> n ; if(!n) break;
		char ch[10]; Team a[10];
		for(int j=0;j<n;j++){
			cin >> ch[j] ;
			int win=0,loose=0;
			for(int i=0;i<n-1;i++){
				int tmp; cin >> tmp ;
				if(tmp==0) win++;
				else if(tmp==1) loose++;
			}
			a[j].x=win,a[j].y=loose,a[j].z=j;
		}
		sort(a,a+n,cmp);
		for(int i=0;i<n;i++){
			cout << ch[a[i].z] << '\n' ;
		}
	}
}