#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    vector<pair<pair<int,int>, char> > team;
    map<int,char> team_n;
    char c;
    int x;
    for(int i=0; i<n; i++){
      cin >>c;
      team_n[-i] = c;
      team.push_back(make_pair(make_pair(0,0),-i));
      for(int j=0; j<n-1; j++){
	cin >>x;
	if(x == 0){team[i].first.first++;}
	if(x == 1){team[i].first.second--;}
      }
    }
    sort(team.begin(),team.end());
    for(int i=team.size()-1; i>=0; i--){
      cout <<team_n[team[i].second]<<endl;
    }
  }
  return 0;
}