/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to Absolute Cinema: https://codeforces.com/problemset/problem/2229/B
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    //Process test cases
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        //Read in lists a and b
        vector<int> a(n), b(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        for(int i = 0; i < n; i++) {
            cin >> b[i];
        }

        //Compute the initial answer by making b always contain
        //the larger of the two values at index i
        long long ans = 0;
        int maxv = 0;
        for(int i = 0; i < n; i++) {
            if(a[i] > b[i]) {
                swap(a[i], b[i]);
            }
            ans += b[i];
            maxv = max(maxv, a[i]);
        }
        //Add the maximum in a to the sum of b
        ans += maxv;

        //Try swapping the elements in each position to improve the answer
        for(int i = 0; i < n; i++) {
            //If b[i] improves the max value in a,
            //the sum will reduce by b[i] - a[i] and the max will increase by b[i] - maxv
            if(b[i] > maxv) {
                ans = max(ans, ans - (b[i] - a[i]) + (b[i] - maxv));
            }
        }

        //Display the answer after testing all options
        cout << ans << endl;
    }
}