#include
using namespace std;
int minVal(int a,int b){
return aa:b;
}
int maxVal(int a,int b){
return a>b?a:b;
}
int Position[1000010];
int main()
{
int n;
int L,num;
int minTime,maxTime;
while(scanf("%d",&n)!=EOF){
while(n--){
scanf("%d%d",&L,&num);
for(int i=0;ii)
scanf("%d",&Position[i]);
minTime=maxTime=0;
for(int i=0;ii){
minTime=maxVal(minTime,minVal(Position[i],L-Position[i]));
maxTime=maxVal(maxTime,maxVal(Position[i],L-Position[i]));
}
printf("%d %d\n",minTime,maxTime);
}
}
return 0;
}