#include <bits/stdc++.h>

#define	endl			"\n"
#define	pb				push_back
#define all(x)			x.begin(), x.end()
#define yash            ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define w()             int t; cin>>t; while(t--)
#define rep(i,a,b)      for(int i=a;i<b;++i)
#define vi 				vector<int>
#define read(v,n)		rep(i,0,n) cin>>v[i];
#define	ll				long long
#define	ull				unsigned long long
#define out(v,n)		rep(i,0,n) {cout<<v[i]<<" ";}

using namespace std;

vector<string> split(const string& s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
	stringstream s; s << "[";
	for (int i = 0; i < n - 1; i++) s << arr[i] << ",";
	s << arr[n - 1] << "]";
	return s.str();
}

#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}

inline void __evars_begin(int line) { cout << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cout << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cout << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cout << val; }
inline void __evars(vector<string>::iterator it) { cout << endl; }

template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
	cout << it->substr((*it)[0] == ' ', it->length()) << "=";
	__evars_out_var(a);
	cout << "; ";
	__evars(++it, args...);
}



void solve() {
	int n,m;
	cin>>n>>m;
	vi max_idx_k(n),costs(m);
	read(max_idx_k,n);
	read(costs,m);
	sort(all(max_idx_k),greater<int>());
	long long total_cost=0;
	for(int i=0; i<n; ++i){
		total_cost+=costs[min(i,max_idx_k[i]-1)];
	}
	/*for(int i=ceil((double)n/2);i<n;++i){
		total_cost+=costs[max_idx_k[i]-1];
	}*/
	cout<<total_cost<<endl;
}

int main()
{
	clock_t begin = clock();
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	yash;
	w()
	solve();
#ifndef ONLINE_JUDGE
	clock_t end = clock();
	cout << "\n\nExecuted In: " << double(end - begin) / CLOCKS_PER_SEC * 1000 << " ms";
#endif
	return 0;
}



