#include using namespace std; using Int=long long; using Real=long double; templateinline bool chmin(T&A,T B){return(A>B?A=B,1:0);} templateinline bool chmax(T&A,T B){return(AC[2<<17]; void sol() { cin>>N>>M>>K; REP(i,N) { int c;cin>>c; C[--c].push_back(i); } Int ans=1e18; REP(i,M)cin>>A[i]; REP(i,M) { int sk=0,mt=0; REP(j,size(C[i])) { while(skC[i][sk])++sk; chmax(mt,sk-j); } chmin(ans,(Int)A[i]*(K-mt)); } cout<>T; while(T--)sol(); }