#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int T, l, n, pos, minans, maxans;
    scanf("%d", &T);
    while (T--)
    {
        minans = 0;
        maxans = 0;
        scanf("%d%d", &l, &n);
        for (int i = 1; i <= n; i++)
        {
            scanf("%d", &pos);
            minans = max(minans, min(pos, l - pos));
            maxans = max(maxans, max(pos, l - pos));
        }
        printf("%d %d\n", minans, maxans);
    }
    return 0;
}
