#include<iostream>

char *team;
int n,**res,wl;
bool* flag;

void display(){
	int count=0;
	flag = new bool[n];
	int tmp = 0;
	for(int i=0; i<n; i++)
		flag[i] = false;
	for(int i=0; i<n; i++)
		if(flag[i])
			std::cout << i << std::endl;
	while(true){
		for(int i=0; i<n; i++){
			if(flag[i] == true)
				continue;
			if(res[tmp][0] < res[i][0])
				tmp = i;
			else if(res[tmp][0] == res[i][0] && res[tmp][1] > res[i][1])
				tmp = i;
		}
		std::cout << team[tmp] << std::endl;
		count++;
		if(count == n)
			return;
		flag[tmp] = true;
		tmp = 0;
		while(flag[tmp]){
			tmp++;
			if(tmp == n)
				tmp = 0;
		}
	}
}

int main(){
	while(true){
		std::cin >> n;
		if(n==0)
			return 0;
		team = new char[n];
		res = new int*[n];
		for(int i=0; i<n; i++){
			res[i] = new int[3];
			for(int k=0; k<3; k++)
				res[i][k] = 0;
		}
		for(int i=0; i<n; i++){
			std::cin >> team[i];
			for(int k=0; k<n-1; k++){
				std::cin >> wl;
				res[i][wl]++;
			}
		}
		display();
		delete[] flag;
		for(int i=0; i<n; i++)
			delete[] res[i];
		delete[] res;
		delete[] team;
	}
}