#include <stdio.h>
int main(){
  int i,j,sa,downmax,upmax,n,m,b[1000];


  scanf("%d",&m);
  for(j=0;j<m;j++){
    downmax = 0;
    upmax = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&b[i]);
      if(i>0){
	if (b[i-1]<b[i] && upmax<b[i]-b[i-1]){
	  upmax = b[i]-b[i-1];
	}
	else if( b[i-1]>b[i] && downmax<(b[i-1]-b[i])){
	    downmax = (b[i-1]-b[i]);
	}
      }
    }
  }
  printf("%d %d\n",upmax,downmax);
    
  return 0;
}