#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
ll n, S = 0;
cin >> n;
vector<vector<ll>> a(n, vector<ll> (3));
for (int i = 0; i < n; i++) cin >> a[i][0];
for (int i = 0; i < n; i++) cin >> a[i][1];
for (int i = 0; i < n; i++) cin >> a[i][2];
for (int i = 0; i < n; i++){
sort(a[i].rbegin(), a[i].rend());
}
S += a[0][0];
for (int i = 1; i < n; i++){
if (a[i][0] == a[i - 1][0]){
if (a[i][1] > a[i - 1][1]){
S += a[i][1];
a[i][0] = -1e18;
} else {
S += a[i - 1][1];
}
} else {
S += a[i][0];
}
}
cout << S << endl;
}
}