/*3次方程式*/
#include<stdio.h>
#include<math.h>
double a, b, c, d;
void fx(){
	double A,B,C;
	double x1,x2;
	int plus=0, minus=0;
/*微分の係数を求める*/
	A = 3*a;
	B = 2*b;
	C = c;
	printf("A = %lf\nB = %lf\nC = %lf\n", A, B, C);
/*二次方程式の解の公式*/
	x1 = (-B+pow((pow(B,2)-4*A*C),0.5))/(2*A);
	x2 = (-B-pow((pow(B,2)-4*A*C),0.5))/(2*A);


/*x1<x2になるように入れ替え */
	if(x1>x2){
		double temp;
		temp = x1;
		x1 = x2;
		x2 = temp;
		
	}
	printf("x1 = %lf\nx2 = %lf\n", x1,x2);
/*極値を求める */
	double fx1,fx2;
	fx1 = a * pow(x1,3) + b * pow(x1,2) + c * x1 + d;
	fx2 = a * pow(x2,3) + b * pow(x2,2) + c * x2 + d;
	printf("fx1 = %lf\nfx2 = %lf\n", fx1,fx2);
/* x=0のときのfx0を求める*/
	double fx0 = d;
	if(x1 == x2) {
		if(x1>0)	plus = 3;
		if(x1<0)	minus = 3;
	}
	else if(x1<0 && x2<0){
		if(fx0 < 0)		{	minus = 3;}	/*fx0 < 0ならば負3つ*/
		else if(fx0 > 0){	minus = 2;	plus = 1;}	/*fx0 > 0ならば負2つ,正1つ*/
		else {				minus = 2;}/*fx0 = 0ならば負2つ*/
	}else if(x1<0 && x2>0){
		if(fx0 < 0)		{	minus = 2;	plus = 1;}/*fx0 < 0ならば負2つ,正1つ*/
		else if(fx0 > 0){	minus = 1;	plus = 2;}/*fx0 > 0ならば負1つ,正2つ*/
		else {				minus = 1;	plus = 1;}/*fx0 = 0ならば負1つ,正1つ*/
	}else if(x1<0 && x2>0){
		if(fx0 < 0)		{	plus = 3;}	/*fx0 < 0ならば正3つ*/
		else if(fx0 > 0){	minus = 1;	plus = 2;}	/*fx0 > 0ならば負1つ,正2つ*/
		else {				plus = 2;}/*fx0 = 0ならば正2つ*/
	}
	printf("%d %d\n", plus, minus);
}

int main(void){
	
	int n=0,i,j;
	int plus=0, minus=0;
	double han;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		plus = 0; minus = 0;
		scanf("%lf %lf %lf %lf ", &a, &b, &c, &d);
		//判別式//
		han = pow(b,2) - 4 * a * c;
		//判別式<0 でないなら、実数解をもつので、３次方程式の微分
		if(han <0){
			printf("%d %d\n", plus, minus);

		}
		else if(han>=0)	fx();
		
	}
}
