#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template< class T > T _abs(T n) { return (n < 0 ? -n : n); } template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); } template< class T > T _min(T a, T b) { return (a < b ? a : b); } template< class T > T sq(T x) { return x * x; } #define ALL(p) p.begin(),p.end() #define MP(x, y) make_pair(x, y) #define SET(p) memset(p, -1, sizeof(p)) #define CLR(p) memset(p, 0, sizeof(p)) #define MEM(p, v) memset(p, v, sizeof(p)) #define CPY(d, s) memcpy(d, s, sizeof(s)) #define SZ(c) (int)c.size() #define PB(x) push_back(x) #define ff first #define ss second #define ld long double #define pii pair< int, int > #define psi pair< string, int > const double EPS = 1e-9; const int INF = 0x7f7f7f7f; struct point { double x,y,z; }; bool eql(point &a,point &b) { return fabs(a.x-b.x)>T; while(T--) { cin>>I>>g[0][1]>>g[1][1]>>g[2][1]>>a>>b>>c>>d; vector < pair < point , point > > r,tr; for(i=0;i<2;i++) { cn=0; x=g[0][i]; for(j=0;j<2;j++) { y=g[1][j]; z=(d-b*y-a*x)/c; if(z>=0 && z<=g[2][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) { r.PB(make_pair(tt[0],tt[1])); continue; } for(j=0;j<2;j++) { z=g[2][j]; y=(d-c*z-a*x)/b; if(y>=0 && y<=g[1][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) r.PB(make_pair(tt[0],tt[1])); else if(cn==3) { bool f=1; for(j=0;j<3 && f;j++) for(l=0;l=0 && z<=g[2][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) { r.PB(make_pair(tt[0],tt[1])); continue; } for(j=0;j<2;j++) { z=g[2][j]; x=(d-c*z-b*y)/a; if(x>=0 && x<=g[0][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) r.PB(make_pair(tt[0],tt[1])); else if(cn==3) { bool f=1; for(j=0;j<3 && f;j++) for(l=0;l=0 && x<=g[0][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) { r.PB(make_pair(tt[0],tt[1])); continue; } for(j=0;j<2;j++) { x=g[0][j]; y=(d-c*z-a*x)/b; if(y>=0 && y<=g[1][1]) { tt[cn].x=x; tt[cn].y=y; tt[cn].z=z; cn++; } } if(cn==2) r.PB(make_pair(tt[0],tt[1])); else if(cn==3) { bool f=1; for(j=0;j<3 && f;j++) for(l=0;l ls; j=0; ls.push_back(r[0].first); j=0; for(i=0;i ls; j=0; ls.push_back(r[0].first); j=0; for(i=0;i