#include <iostream>
#include <map>
#include <sstream>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.baseballchamp", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0 ){
			break;
		} // end if
		
		multimap<int, pair<int, char> > rank;
 
		int i,j;
		for (i = 0; i < n; ++i){
			getline (cin, str );
			char name;
			int in;
			int win = 0, lose = 0, draw = 0;
			
			stringstream ss(str);
			ss >> name;
			
			for (j = 0; j < n - 1; ++j){
				ss >> in;
				switch (in ){
					case 0: ++win; break;
					case 1: ++lose; break;
					case 2: ++draw; break;
				} // end switch
			} // end for
			rank.insert (make_pair (-win , make_pair (lose, name ) ) );
		} // end for
		
		multimap<int, pair <int, char> >::iterator it = rank.begin();
			
		for (; it != rank.end(); ++it ){
			cout << (*it).second.second << endl;
		} // end for
	} // end loop
		
	return 0;
}