import java.util.Scanner;

public class maks
{
    static int N, T, res;
    static int[] A, B, C;

    static void search(int n, int solved, int a, int b, int c)
    {
        if (n < N)
        {
            if (A[n] >= 0 && a + A[n] <= T) search(n + 1, solved + 1, a + A[n], b, c);
            if (B[n] >= 0 && b + B[n] <= T) search(n + 1, solved + 1, a, b + B[n], c);
            if (C[n] >= 0 && c + C[n] <= T) search(n + 1, solved + 1, a, b, c + C[n]);
            search(n + 1, solved, a, b, c);
        }
        else
        {
            if (solved > res)
                res = solved;
        }
    }

    static int[] readTimes(Scanner sc)
    {
        int[] times = new int[N];
        for (int n = 0; n < N; ++n)
            times[n] = sc.nextInt();
        return times;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int cases = sc.nextInt();
        while (cases-- > 0)
        {
            N = sc.nextInt();
            T = sc.nextInt();
            A = readTimes(sc);
            B = readTimes(sc);
            C = readTimes(sc);
            res = 0;
            search(0, 0, 0, 0, 0);
            System.out.println(res);
        }
    }
}
