#include <iostream.h>
#include <iomanip.h>
#include <math.h>

const double PI = 3.14159;

int main()
{
	double front[3], back[9], diam, target;
	int ncases, i;
	cin >> ncases;
	for(int icases=1; icases<=ncases; icases++) {
		for(i=0; i<3; i++)
			cin >> front[i];
		for(i=0; i<9; i++)
			cin >> back[i];
		cin >> diam >> target;
		diam *= PI;

		double closest = target;
		int f, b;
		double size;
		for(i=0; i<3; i++) {
			for(int j=0; j<9; j++) {
				double temp = fabs(target - diam*front[i]/back[j]);
				if (fabs(temp-closest) < 0.000001 && front[i] < f) {
					f = front[i];
					b = back[j];
					size = diam*front[i]/back[j];
					closest = temp;
				}
				else if (temp < closest) {
					f = front[i];
					b = back[j];
					size = diam*front[i]/back[j];
					closest = temp;
				}
			}
		}
		int intsize = (int)(1000*size + 0.5);
		size = intsize/1000.0;
		cout << "A gear selection of " << f << '/' << b;
		cout << " produces a gear size of " << size;
		if (intsize % 1000 == 0)
			cout << ".000";
		else if (intsize % 100 == 0)
			cout << "00";
		else if (intsize % 10 == 0)
			cout << "0";
		cout << "." << endl;
		if (icases != ncases)
			cout << endl;
	}
	return 0;
}
