#include <cstdio>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int n,totaltime;
int x[3][10];

int mem[1<<10][3][301];
int go(int left,int cur,int t) {
	if(cur>=3) return 0;
	int &ret=mem[left][cur][t];
	if(ret==-1) {
		ret=go(left,cur+1,totaltime);
		REP(i,n) if(x[cur][i]!=-1&&left&(1<<i)&&x[cur][i]<=t) ret=max(ret,1+go(left-(1<<i),cur,t-x[cur][i]));
	}
	return ret;
}

void run() {
	scanf("%d%d",&n,&totaltime);
	REP(i,3) REP(j,n) scanf("%d",&x[i][j]);
	memset(mem,-1,sizeof(mem));
	printf("%d\n",go((1<<n)-1,0,totaltime));
}

int main() {
	int n; scanf("%d",&n); REP(i,n) run();
	return 0;
}
