#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	while( cin >> n , n ){
		// pair<int,P> Í (¿,-¯,-üÍ³ê½Ô)
		// char Í`[¼(At@xbg1¶)
		char c[12] = {0};
		vector<pair<int,P> > v;
		
		for(int i=0 ; i < n ; i++ ){
			char t;
			int win=0, lose=0;
			cin >> t;
			c[i] = t;
			for(int j=0 ; j < n-1 ; j++ ){
				int r;
				cin >> r;
				if( r == 0 ){
					win++;
				}else if( r == 1 ){
					lose++;
				}
			}
			// pair<int,P> Í (¿,-¯,-üÍ³ê½Ô)
			P p( -lose , -i );
			pair<int,P> p_(win,p);
			v.push_back( p_ );
		}
		sort( v.rbegin() , v.rend() );
		for(int i=0 ; i < v.size() ; i++ ){
			cout << c[ -v[i].second.second ] << endl;
		}
	}
}