#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define max3(a,b,c) max(a,max(b,c))
double PI=acos(-1.0);
ll ans22=0;
int dp[1005][1005][2];
int x,y;
int n;
vector<int> a(1005);
vector<int> b(1005);
// dp denotes what is the minimum cost to transform the array a starting 
// at "index" with last 0 or 1 placed at "lindex" uptil "index-1"
// ie if we have transform array like 1 1 1 0 0 0 0
// we are at index 7 (0 indexing) then our dp state will be like dp(7,3,0) ie we placed 0 from index 3-6
int fun(int index,int lindex,int f)
{
	if(index==n)
	{
		if(n-lindex>=x && n-lindex<=y)return 0;
		else return 1e8;
	}

	int &res=dp[index][lindex][f];
	if(res!=-1)
		return res;
    res=1e8;
	
	if(f==0){
		int cost=(a[index]==0)?0:b[index];    //placing 0 at "index" and check if we need to flip or not,if yes cost=b[index]
		int pos1=index-lindex+1;              //we calculated the size of subarray ending at "index" which contains only 0
		if(pos1>=x && pos1<=y)res=min(res,cost+fun(index+1,lindex,0));//if size of this subarray fits the criteria we can put 0 at this index
        
        pos1=index-lindex;                    //we calculated the size of subarray ending at "index-1" which contains only 0
		cost=(a[index]==1)?0:b[index];       //placing 1 at "index" and check if we need to flip or not,if yes cost=b[index]
		
		if(pos1>=x && pos1<=y)
		res=min(res,cost+fun(index+1,index,1));//if size of this subarray fits the criteria we can put 1 at this index
	}else{//same as above 
		int cost=(a[index]==0)?0:b[index];
		int pos1=index-lindex;                 //we calculated the size of subarray ending at "index-1" which contains only 1
		if(pos1>=x && pos1<=y)
		res=min(res,cost+fun(index+1,index,0));//if size of this subarray fits the criteria we can put 0 at this index
		
		pos1=index-lindex+1;                   //we calculated the size of subarray ending at "index" which contains only 1
		cost=(a[index]==1)?0:b[index];              
		if(pos1>=x && pos1<=y)res=min(res,cost+fun(index+1,lindex,1));//placing 1 after checking criteria
	}

	return res;

}


int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);                      //input n
		scanf("%d%d",&x,&y);                 //input x y
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);               //input A 
		for(int i=0;i<n;i++)
			scanf("%d",&b[i]);              //input B
		memset(dp,-1,sizeof dp);

		int ans=1e8;

		int cost=(a[0]==0)?0:b[0];          //placing 0 at first index and check if we need to flip or not,if yes cost=b[0]
		ans=min(ans,cost+fun(1,0,0));

		cost=(a[0]==1)?0:b[0];              //placing 1 at first index and check if we need to flip or not,if yes cost=b[0]
		ans=min(ans,cost+fun(1,0,1));

		printf("%d\n",ans);
	}

	return 0;
}