#include<iostream>
#include<string>

using namespace std;

int main()
{
	int i, n;
	int a[4] = {0}, b[4] = {0};		//ツ係ツ青板行ツ療ア+ツ逆ツ行ツ療ア
	int ans1, ans2;		//ツ督堋つヲ
	
	cin >> n;
	for(i = 0; i < n; i++){
		a[3] = b[2] = 0;
		b[3] = a[2] = 1;
		
		cin >> a[0] >> a[1] >> ans1 >> b[0] >> b[1] >> ans2;
		
		double temp = -1*(b[0]/a[0]);
		for(int j = 0; j < 4; j++){
			b[j] = temp*a[j] +b[j];
		}
		temp = -1*(a[1]/b[1]);
		cout << temp << endl;
		for(int j = 0; j < 4; j++){
			a[j] = temp*b[j] + a[j];
		}
		if(a[0] != 1){
			if(a[0] < 0){
				temp = -1/a[0];
			}
			else{
				temp = 1/a[0];
			}
			for(int j = 0; j < 4; j++){
				a[j] = temp*a[j];
			}
		}
		if(b[1] != 1){
			if(b[1] < 0){
				temp = 1/b[1];
			}
			else{
				temp = 1/b[1];
			}
			for(int j = 0; j < 4; j++){
				b[j] = temp*b[j];
			}
		}
		/*
		for(int j = 0; j < 4; j++){
			cout << a[j] << " " ;
		}
		cout << endl;
		for(int j = 0; j < 4; j++){
			cout << b[j] << " " ;
		}
		*/
		cout << a[2]*ans1 + a[3]*ans2 << endl;
		cout << b[2]*ans1 + b[3]*ans2 << endl;
	}
}