#include<iostream>
#include<algorithm>
using namespace std;

#define int long long
const int MOD = 998244353;
const int OFS = 1e9;
const int N = 15;
int n, m, k;
int x[N];
int T;

int qpow(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) res = (res * a) % MOD;
		b >>= 1;
		a = (a * a) % MOD;
	}
	return res;
}

void solve(){
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i ++){
		int a; cin >> a;
		x[i] = OFS + a;
	}
	for(int i = 1;i <= n;i ++){
		int a; cin >> a;
		x[i + n] = 2 * OFS + a;
	}
	int cnt = 0; int ans = 0;
	do{
		int mul = 1, add = 0;
		for(int i = 1;i <= k;i ++){
			if(x[i] / OFS == 1){
				add = max(add, x[i] % OFS);
			}
			else{
				mul = (mul * (x[i] % OFS)) % MOD;
			}
		}
		cnt ++;
		ans = (ans + mul * add) % MOD;
	}while(next_permutation(x + 1, x + 2 * n + 1));
//	cout << ans << '\n';
//	cout << cnt << '\n';
	cout << ans * qpow(cnt, MOD - 2) % MOD << '\n';
}

signed main(){
//	freopen("5.in", "r", stdin);
//	freopen("5.out", "w", stdout);
	cin.tie(0) -> ios::sync_with_stdio(0);
	
	cin >> T;
	
	while(T --){
		solve();
	}
	return 0;
}
