#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef pair<int, char> P;
typedef pair<int, P> P2;

int main(){
  int n;
  char name;
  P2 team[11];
  while(cin >> n, n){
    for(int i = 0 ; i < n ; i++){
      team[i].first = 0;
      team[i].second.first = 0;
    }
    
    int op;
    for(int i = 0 ; i < n ; i++){
      cin >>team[i].second.second;
      for(int j = 0 ; j < n-1 ; j++){
	cin >> op;
	if(op == 0) team[i].first++;
	if(op == 1) team[i].second.first++;
      }
    }
    
    for(int i = 0 ; i < n ; i++){
      team[i].second.first *= -1;
    }
    
    sort(team, team+n);
    reverse(team, team+n);
    
    for(int i = 0 ; i < n ; i++){
      cout << team[i].second.second << endl;
    }
  }
  return 0;
}

    
	