#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,f,n;
/*ax+by=c;
dx+ey=f;
=aex+bey=ce;
=dbx+bey=fb;
aex-dbx=ce-fb;
=x(ae-db)=ce-fb;
x=(c*e-f*b)/(a*e-d*b);
y=(c-(c*e-f*b)/(a*e-d*b)*a)/b;
*/
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a>>b>>c>>d>>e>>f;
printf("%d %d\n",(c*e-f*b)/(a*e-d*b),(c-(c*e-f*b)/(a*e-d*b)*a)/b);
}
}