#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, int> ppp;
typedef pair<ppp, char> pppp;

const int W = 0, L = 1;

int main()
{
    int n;
    while(cin >> n && n)
    {
        vector<pppp> ans;
        REP(n)
        {
            int w = 0, l = 0, r = 0;
            char t; cin >> t;
            rep(j,n- 1)
            {
                cin >> r;
                if(r == W) w++;
                if(r == L) l++;
            }
            ans.push_back(pppp(ppp(pp(-w, l),i), t));
        }
        sort(all(ans));

        REP(n) cout << ans[i].second << endl;
    }
    return 0;
}