// Arup Guha
// 4/1/2013
// Solution to 2013 FHSPS Problem Coupon-Palooza

import java.util.*;

public class coupon {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each item.
		for (int loop=0; loop<numCases; loop++) {

			// Read in the original price.
			double price = stdin.nextDouble();

			// Make all the subtractive discounts one effective discount.
			double dollarsOff = 0;
			int numSub = stdin.nextInt();
			for (int i=0; i<numSub; i++)
				dollarsOff += stdin.nextDouble();

			// Make all the multiplicative discounts one effective discount.
			double ratioPay = 1;
			int numPercOff = stdin.nextInt();
			for (int i=0; i<numPercOff; i++)
				ratioPay *= ((100.0-stdin.nextDouble())/100.0);

			// Be greedy here, first apply the percentage off, then the straight discounts.
			// Reason: Let p = ratio discount and q = subtractive discount. Two options for original price x are:
			//         (1) (x - q)p = px - pq, or (2) px - q, since p < 1, pq < q, so the second option subtracts more.
			System.out.printf("%.2f\n", price*ratioPay - dollarsOff);
		}
	}
}