#include <stdio.h>
int GetPoint(void)
{
	int i, curr, sum=0;
	for(i=0; i<5; i++)
	{
		scanf("%d", &curr);
		sum += curr;
	}
	return sum;
}

int main(void)
{
	int i, n, curr, max, min;
	while(1)
	{
		scanf("%d", &n);
		if(n==0)break;

		curr=GetPoint();
		max=curr; min=curr;
		for(i=1; i<n; i++)
		{
			curr=GetPoint();
			     if(curr > max)max = curr;
			else if(curr < min)min = curr;
		}
		printf("%d %d\n", max, min); 
	}
	return 0;
}