// Arup Guha
// 2/3/2014
// Solution to 2014 UCF HS Online Contest Problem: Broken Galleti

import java.util.*;

public class broken {

	final public static int NOSOLUTION = -1;
	final public static int MINANS = 3;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Lots of data to read in...
			int numFunky = stdin.nextInt();
			int numDark = stdin.nextInt();
			int a = stdin.nextInt();
			int b = stdin.nextInt();
			int c = stdin.nextInt();
			int d = stdin.nextInt();
			int[] funky = new int[numFunky];
			for (int i=0; i<numFunky; i++)
				funky[i] = stdin.nextInt();
			int[] dark = new int[numDark];
			for (int i=0; i<numDark; i++)
				dark[i] = stdin.nextInt();

			// Put all solutions here.
			ArrayList<triplet> sols = new ArrayList<triplet>();

			// Search for valid solutions.
			for (int i=0; i<numFunky; i++) {
				for (int j=0; j<numDark; j++) {

					// This isn't allowed.
					if (funky[i] >= dark[j]) continue;

					// Try this out and add if it's valid.
					int ans = solve(a, b, c, d, funky[i], dark[j]);
					if (ans >= MINANS) sols.add(new triplet(funky[i], dark[j], ans));
				}
			}

			// Sort in the order they want.
			Collections.sort(sols);

			// Output all solutions.
			System.out.println("Starship #"+loop+":");
			System.out.println("There are "+sols.size()+" possible reactor combinations.");
			for (int i=0; i<sols.size(); i++)
				System.out.println(sols.get(i));
			System.out.println();
		}
	}

	public static int solve(int a, int b, int c, int d, int x1, int x2) {

		// Need to use long since b*b*(x1+x2) might overflow int...
		// These are the important constants in the equation used to solve for the
		// number of parts.
		long div = a*d - b*c;
		long lhs = ((long)b)*d*(x1+x2) - 2*b*c;

		// Flip the divisor to be positive, if necessary.
		if (div < 0) {
			div = -div;
			lhs = -lhs;
		}

		// Cases where there is no solution...
		if (lhs <= 0 || lhs%div != 0) return NOSOLUTION;

		// Otherwise the division of these two is the number of parts.
		return (int)(lhs/div);
	}
}

class triplet implements Comparable<triplet> {

	public int funkyMass;
	public int darkMass;
	public int parts;

	public triplet(int a, int b, int c) {
		funkyMass = a;
		darkMass = b;
		parts = c;
	}

	// Follow the directions here.
	public int compareTo(triplet other) {
		if (this.parts != other.parts)
			return this.parts - other.parts;
		if (this.funkyMass != other.funkyMass)
			return this.funkyMass - other.funkyMass;
		return this.darkMass - other.darkMass;
	}

	// What the output spec wants.
	public String toString() {
		return parts+" parts, funky matter reactor mass "+funkyMass+", dark matter reactor mass "+darkMass+".";
	}
}