#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int num;
  char name;
  int win;
  int lose;
  int drow;
}TEAM;
main(){
  int n;
  TEAM team[15];
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin>>team[i].name;
      team[i].win=0;
      team[i].lose=0;
      team[i].drow=0;
      team[i].num=i;
      int a;
      for(int j=0;j<n-1;j++){
	cin>>a;
	if(a==0){
	  team[i].win++;
	}
	else if(a==1){
	  team[i].lose++;
	}
	else{
	  team[i].drow++;
	}
      }
    }
    for(int i=1;i<n;i++){
      for(int j=i;j>0;j--){
	if(team[j].win>team[j-1].win||(team[j].win==team[j-1].win&&team[j].lose<team[j-1].lose)||(team[j].win==team[j-1].win&&team[j].lose==team[j-1].lose&&team[j].num<team[j-1].num)){
	  TEAM temp;
	  temp=team[j];
	  team[j]=team[j-1];
	  team[j-1]=temp;
	}
      }
    }
    for(int i=0;i<n;i++){
      cout<<team[i].name<<endl;
    }
  }
}
    