#include <bits/stdc++.h>
using namespace std;
const int N=200+5;
int n;
int a[15];
map<int,int>mp;
int lgg(int x){
int t=0;
while(x!=0){
x/=10;t++;
}
return t;
}
int main(){
freopen ("numlg.in","r",stdin);
freopen ("numlg.out","w",stdout);
int T;scanf("%d",&T);
while(T--){
scanf("%d",&n);
mp.clear();
memset(a,0,sizeof(a));
for (int i=1;i<=n;i++){
int x;scanf("%d",&x);
mp[x]++;
}
for (int i=1;i<=n;i++){
int x;scanf("%d",&x);
mp[x]--;
}
int &x=mp[1e9],ans=0;
if (x!=0){
mp[10]+=x;ans+=abs(x);
x=0;
}
map<int,int>::iterator iter;
for (iter=mp.begin();iter!=mp.end();iter++){
int p=iter->first,q=iter->second;
if (q!=0){
iter->second=0;
if (p<=9)a[p]+=q;
else a[lgg(p)]+=q,ans+=abs(q);
}
}
for (int i=2;i<=9;i++)ans+=abs(a[i]);
printf("%d\n",ans);
}
return 0;
}