#include <bits/stdc++.h>
using namespace std;

struct Team
{
    int win, lose, num;
    char name;

    Team () {}
    Team ( int win, int lose, char name, int num) : win(win), lose(lose), name(name), num(num) {}

    bool operator < ( const Team &d ) const
    {
        return ( win < d.win || win == d.win && (lose > d.lose || lose == d.lose && num > d.num));    }

    bool operator > ( const Team &d ) const
    {
        return ( !(*this < d) );
    }
};

int main()
{
    int N;
    Team data[15];

    while ( cin >> N, N ) {
        for ( int i = 0; i < N; i++ ) {
            int win = 0, lose = 0;
            char name;
            cin >> name;
            for ( int j = 0; j < N - 1; j++ ) {
                int d;
                cin >> d;
                switch ( d ) {
                    case 0 :
                        win++;
                        break;
                    case 1 :
                        lose++;
                        break;
                }
            }
            data[i] = Team ( win, lose, name, i );
        }
        sort ( data, data + N, greater<>());
        for ( int i = 0; i < N; i++ ) {
            cout << data[i].name << endl;
        }
    }

    return ( 0 );
}
