#include<iostream>
using namespace std;
int main()
{
	long t,**q,**p,i,min,*y,flag,r,*l,c,max,*s,o,f,k,u;
	while(cin >> t && t!= 0)
	{
		q = new long*[t];
		p = new long *[t];
		y = new long[t];
		l = new long[t];
		s = new long[t];
		for( i=0; i<t;i++)
		{
			q[i] = new long[t];
			p[i] = new long[t];
		}

			for( r = 0; r< t; r++)
					for( c = 0; c < t;c++)
					{
						p[r][c] = 0;
						cin >> q[r][c];
					}
		for( r = 0; r < t; r++)
		{
			o=0;
			min = 1000000;
			l[o] = r;
			y [o]= 0;
			
		for( c = 0; c < t;c++)
		{
			if(q[r][c] <= min)
			{
				if(min == q[r][c])
				{
					o++;
				min = q[r][c];
				l[o]= r;
				y[o] =c;
				}
				else 
				{
				o = 0;
				min = q[r][c];
				l[o]= r;
				y[o] =c;
				}
			}
		}
		for(f = 0; f <= o;f++)
		p[l[f]][y[f]]++;
		}
		for( c = 0; c< t; c++)
		{
		
			max= -1;
			o=0;
			l[o] = 0;
			y[o] = c;
		for( r = 0; r < t;r++)
		{
			if(q[r][c] >= max)
			{
				if(max == q[r][c])
				{
					o++;
			      max = q[r][c];
				  l[o]= r;
				  y[o] =c;
				}
				else
				{
				o = 0;
				max = q[r][c];
				  l[o]= r;
				  y[o] =c;
				}
			}
		}
		for(f = 0; f <= o;f++)
		p[l[f]][y[f]]++;
		}
			flag = 0;
			long count = 0;
			for(c = 0 ; c < t; c++)
				for(r =0; r<t;r++)
				{
					if(p[c][r] == 2 )
					{
						for( u = 0; u < count ;u++)
						{
					     if (s[u] == q[c][r])
							 break;
						}
						if(u >= count)
						{
							flag++;
							s[count] = q[c][r];
							count++;
						    
						}
					}
				}
				if(flag == 0)
					cout << 0 << endl;
				else
				{
                    for(k = 0; k < count;k++)
					{
						cout << s[k];
						if(k < count -1)
							cout << " ";
						else
					   cout << endl;
					}
				}
				}
	return 0;
}