#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
/*
struct Team {
    char t;
    int win, lose;
    bool operator < (const Team& team_) const {
        return win == team_.win ? lose > team_.lose : win < team_.win;
    }
};

Team team[11];
*/
int score[11];
int score2[11];
char team[11];
bool check[11];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n && n){
        for(int i = 0; i < n; ++i){
           // cin >> team[i].t;
            cin >> team[i];
            score[i] = 0;

            for(int j = 0; j < n - 1; ++j){
                int a;
                cin >> a;
                /*if(a == 0) ++team[i].win;
                if(a == 1) ++team[i].lose;*/
                if(a == 0) score[i] += 100;;
                if(a == 1) score[i] --;
            }
            score2[i] = score[i];
            check[i] = true;
        }

        sort(score, score + n, greater<int>());
/*
        for(int i = n - 1; i >= 0; --i){
            cout << team[i].t << endl;
        }*/
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if(score[i] == score2[j] && check[j]){
                    cout << team[j] << endl;
                    check[j] = false;
                    break;
                }
            }
        }
    }

    return 0;
}