#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{ 
  while(1){
    int n;
    cin>>n;

    if(n == 0){
      break;
    }
    
    vector<pair<int,char>> total_result;
    int result;

    for(int i = 0;i < n;++i){
      int point = 0;
      char name;
      cin>>name;

      for(int j = 0;j < n - 1;++j){
        cin>>result;
        if(result == 0){
          point += 100;
        }
        else if(result == 2){
          point += 1;
        }
      }

      total_result.push_back(make_pair(point,name));
    }

    sort(total_result.begin(),total_result.end());
    reverse(total_result.begin(),total_result.end());

    for(int i = 0;i < n;++i){
      cout<<total_result[i].second<<endl;
    }
  }
  return 0;
}
