#include<stdio.h>
#include<stdlib.h>
int compar(const void *a, const void *b) {
if (*(int*)a < *(int*)b) return -1;
if (*(int*)a == *(int*)b) return 0;
return 1;
}
int main(){
int c,n,w[10000],m[10000],i,sum,t;
scanf("%d",&c);
while(c--){
scanf("%d", &n);
for(i=0; i<n; i++) scanf("%d", &w[i]);
for(i=0; i<n; i++) scanf("%d", &m[i]);
qsort((void *)w, n, sizeof(int), compar);
qsort((void *)m, n, sizeof(int), compar);
sum = 0;
for(int i=0; i<n; i++){
t = w[i] - m[i];
if(t < 0) t = -t;
sum += t;
}
printf("%d\n", sum);
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CmludCBjb21wYXIoY29uc3Qgdm9pZCAqYSwgY29uc3Qgdm9pZCAqYikgewogIGlmICgqKGludCopYSA8ICAqKGludCopYikgcmV0dXJuIC0xOwogIGlmICgqKGludCopYSA9PSAqKGludCopYikgcmV0dXJuICAwOwogIHJldHVybiAxOwp9CgppbnQgbWFpbigpewoJaW50IGMsbix3WzEwMDAwXSxtWzEwMDAwXSxpLHN1bSx0OwoJc2NhbmYoIiVkIiwmYyk7CgoJd2hpbGUoYy0tKXsKCQlzY2FuZigiJWQiLCAmbik7CgkKCQlmb3IoaT0wOyBpPG47IGkrKykgc2NhbmYoIiVkIiwgJndbaV0pOwoJCWZvcihpPTA7IGk8bjsgaSsrKSBzY2FuZigiJWQiLCAmbVtpXSk7CgkKCQlxc29ydCgodm9pZCAqKXcsIG4sIHNpemVvZihpbnQpLCBjb21wYXIpOwoJIAlxc29ydCgodm9pZCAqKW0sIG4sIHNpemVvZihpbnQpLCBjb21wYXIpOwoJCgkJc3VtID0gMDsKCQlmb3IoaW50IGk9MDsgaTxuOyBpKyspewoJCQl0ID0gd1tpXSAtIG1baV07CgkJCWlmKHQgPCAwKSB0ID0gLXQ7CgkJCXN1bSArPSB0OwoJCX0KCQoJCXByaW50ZigiJWRcbiIsIHN1bSk7Cgl9CgoJcmV0dXJuIDA7Cn0=