#include<iostream>
#include<map>
#define mp make_pair
using namespace std;
int main(){
  while(true){
    int n,a;
    cin>>n;
    if(!n)break;
    char name[n];
    int score;
    multimap<int, int> teams;
    for(int i=0;i<n;i++){
      cin>>name[i];
      score = 0;
      for(int j=0;j<n-1;j++){
	cin>>a;
	if(a==0)score-=100;
	if(a==1)score++;	
      }
      teams.insert(mp(score,i));
    }
    map<int, int>::iterator it = teams.begin();
    while( it != teams.end() ){
      cout << name[(*it).second] << endl;
      it++;
    }
  }
  return 0;
}