#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

class Team{
public:
	char name;
	int win;
	int lost;
	int number;

	bool operator>( const Team& lhs ) const{
		if( win > lhs.win ){
			return true;
		}else if( win < lhs.win ){
			return false;
		} else if( win == lhs.win ){
			if( lost > lhs.lost ){
				return false;
			} else if( lost < lhs.lost ) {
				return true;
			}
		}
		if( number < lhs.number ){
			return true;
		} else {
			return false;
		}
	}

	bool operator<( const Team& lhs ) const{
		if( win < lhs.win ){
			return true;
		}else if( win > lhs.win ){
			return false;
		} else if( win == lhs.win ){
			if( lost < lhs.lost ){
				return false;
			} else if( lost > lhs.lost ) {
				return true;
			}
		}
		if( number > lhs.number ){
			return true;
		} else {
			return false;
		}
	}
};

int main(void)
{
	Team team[11];
	int n;
	int input_data[11];
	char input_name;

	while( cin >> n && n != 0 ){
		for( int i = 0;i < 11;i++ ){
			team[i].win = team[i].lost = team[i].name = team[i].number = 0;
		}

		for( int i = 0;i < n;i++ ){
			cin >> input_name;
			for( int j = 0;j < n - 1;j++ ){
				cin >> input_data[j];
				if( input_data[j] == 0 ) team[i].win++;
				else if( input_data[j] == 1 ) team[i].lost++;
			}

			team[i].name = input_name;
			team[i].number = i;
			
		}

		stable_sort( team, team + n, greater<Team>() );

		for( int i = 0;i < n;i++ ) cout << team[i].name << endl;


	}
	
	return 0;
}