#include <iostream>   
using namespace std;   
  
int main()   
{   
    int n;   
    while (cin >> n, n)   
    {   
        char name[10];   
        int win[10] = {0};   
        int lose[10] = {0};   
  
        for (int i = 0; i < n; ++i)   
        {   
            cin >> name[i];   
            for (int j = 0; j < n - 1; ++j)   
            {   
                int s;   
                cin >> s;   
                if (s == 0)   
                    win[i]++;   
                if (s == 1)   
                    lose[i]++;   
            }   
        }   
  
        for (int i = n - 1; i > -1; --i)   
            for (int j = 0; j < n - i; ++j)   
                for (int k = 0; k < n; ++k)   
                    if (win[k] == i && lose[k] == j)   
                        cout << name[k] << endl;   
  
    }   
  
    return 0;   
}  