#include #include #include #include #include #include #include #include #define dig(...) fprintf(stderr, __VA_ARGS__) template void read(TAT &a) { static char cc; static bool fff; while (((cc = getchar()) < '0' || cc > '9') && cc != '-'); if (cc == '-') fff = 1, a = 0; else fff = 0, a = cc - 48; while ((cc = getchar()) >= '0' && cc <= '9') a = a * 10 + cc - 48; if (fff) a = -a; } template void write(TAT a) { static char cc[25]; static int ct; if (a < 0) putchar('-'), a = -a; if (a == 0) {putchar('0'); return;} ct = 0; while (a) cc[++ct] = a % 10 + 48, a /= 10; while (ct) putchar(cc[ct--]); } void begin() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } void end() { fclose(stdin); fclose(stdout); } using namespace std; const int maxn = 100005; int n, m; int A[maxn]; int B[maxn]; void Init() { read(n), read(m); for (int i = 1; i <= n; ++i) read(A[i]); for (int i = 1; i <= m; ++i) read(B[i]); } void Solve() { register long long S = 0; register long long Max = -2e9; register int cnt = 0; register int nt = 0, last = 0; sort(A + 1, A + 1 + n); sort(B + 1, B + 1 + m); for (int i = 1; i <= n; ++i) { if (nt == m) break; if (A[i] >= B[nt + 1]) { ++cnt; ++nt; } } for (int i = n, j = 1; cnt >= 1; --i, ++j, --cnt) { S += A[i] - B[j]; Max = max(Max, S); } cout << Max << endl; } int main() { register int T; read(T); while (T--) { Init(); Solve(); } return 0; }