#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, int> pp;
typedef pair<pp, char> ppp;

const int W = 0, T = 1, L = 1, MAXN = 11;


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

        vector<ppp> ans;
            int w[MAXN] = {}, l[MAXN] = {};
            bool used[MAXN] = {};
            char t[MAXN];

        REP(n)
        {
            int r;//, w = 0, l = 0;
            cin >> t[i];
            rep(j,n - 1)
            {
                cin >> r;
                if(r == W)w[i]++;
                if(r == L)l[i]++;
            }
        }
        rep(j,n)
        {
            int maxw = 0, minl = n, f = n;
            REP(n)
               if(!used[i] &&( (maxw < w[i] ) || (maxw == w[i] && minl > l[i]))){ f = i; maxw = w[i]; minl = l[i];}
            used[f] = true;
            cout << t[f] << endl;
        }
    }
    return 0;
}