#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double eps=1e-9;
int a,b,c,d;
inline double f(double x){
	return x*x*x*a+x*x*b+x*c+d;
}
inline double ABS(double x){return max(x,-x);}
int main(){
	int t;scanf("%d",&t);
	while(t--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(a<0){
			a=-a;b=-b;c=-c;d=-d;
		}
		int r1=0;
		int r2=0;
		int D=b*b-3*a*c;
		if(D<0){
			if(f(0)<-eps)r1++;
			if(f(0)>eps)r2++;
		}else if(D==0){
			double t=(double)-b/3/a;
	//		printf("%f\n",t);
			if(ABS(f(t))<eps){
				if(t>eps)r1+=3;
				if(t<-eps)r2+=3;
			}else{
				if(f(0)<-eps)r1++;
				if(f(0)>eps)r2++;
			}
		}else{
			double t1=((double)-b-sqrt(D))/3/a;
			double v1=f(t1);
			double t2=((double)-b+sqrt(D))/3/a;
			double v2=f(t2);
			double v0=f(0);
		//	printf("%f %f %f %f\n",t1,v1,t2,v2);
			if(ABS(v1)<eps){
				if(t1<-eps)r2+=2;
				if(t1>eps)r1+=2;
			}else if(v1>eps){
				if(t1<-eps)r2++;
				else{
					if(v0>eps)r2++;
					if(v0<-eps)r1++;
				}
				if(ABS(v2)<eps){
					if(t2<-eps)r2+=2;
					if(t2>eps)r1+=2;
				}else if(v2<-eps){
					if(t2<-eps)r2++;
					else if(t1>eps)r1++;
					else{
						if(v0>eps)r1++;
						if(v0<-eps)r2++;
					}
				}
			}
			if(v2<-eps){
				if(t2>eps)r1++;
				else{
					if(v0>eps)r2++;
					if(v0<-eps)r1++;
				}
			}
		}
		printf("%d %d\n",r1,r2);
	}
}