#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
using ll = int64_t;

bool greater(ll const& a,ll const& b)noexcept{
    return a>b;
}

int main(){
    ll t;
    std::cin>>t;
    while(t--){
        ll n,m,h;
        std::cin>>n>>m>>h;
        const ll maxn{ll(1e5+5)};
        static std::vector<ll> bty(maxn);
        for(ll i{1};i<=n;i++){
            std::cin>>bty[i];
        }
        static std::vector<ll> pw(maxn);
        for(ll i{1};i<=m;i++){
            std::cin>>pw[i];
        }
        std::sort(bty.data()+1,bty.data()+1+n,greater);
        std::sort(pw.data()+1,pw.data()+1+m,greater);
        const ll minNm{std::min(n,m)};
        ll ans{};
        for(ll i{1};i<=minNm;i++){
            ans+=(h*pw[i]>bty[i]?bty[i]:h*pw[i]);
        }
        std::cout<<ans<<'\n';
    }
}