#include <iostream>
using namespace std;

struct Team {

	char name;
	int  winCnt;
	int  loseCnt;

};

int main()
{

	int n, r;
	int inInfo[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
	Team t[10];

	while( cin >> n, n ) {

		for( int i = 0; i < 10; i++ ) { t[i].winCnt = 0; t[i].loseCnt = 0; }

		for( int i = 0; i < n; i++ ) {
			cin >> t[i].name;
			for( int j = 0; j < n - 1; j++ ) {

				cin >> r;
				if( r == 0 ) t[i].winCnt++;
				else if( r == 1 ) t[i].loseCnt++;

			}
		}

		for( int i = 0; i < n - 1; i++ ) {
			for( int j = i + 1; j < n; j++ ) {

				int  itemp;
				Team stemp;

				if( t[i].winCnt == t[j].winCnt ) {
					if( t[i].loseCnt == t[j].loseCnt ) {
						if( inInfo[i] > inInfo[j] ) {

							stemp = t[i];  itemp     = inInfo[i];
							t[i]  = t[j];  inInfo[i] = inInfo[j];
							t[j]  = stemp; inInfo[j] = itemp;

						}
					}
					if( t[i].loseCnt > t[j].loseCnt ) {

						stemp = t[i];  itemp     = inInfo[i];
						t[i]  = t[j];  inInfo[i] = inInfo[j];
						t[j]  = stemp; inInfo[j] = itemp;

					}
				}
				else if( t[i].winCnt < t[j].winCnt ) {

						stemp = t[i];  itemp     = inInfo[i];
						t[i]  = t[j];  inInfo[i] = inInfo[j];
						t[j]  = stemp; inInfo[j] = itemp;

				}

			}
		}

		for( int i = 0; i < n; i++ ) cout << t[i].name << endl;

	}

	return 0;

}