#include<iostream>
#include<cmath>
using namespace std;
const double eps = 1e-9;

bool eq(double a, double b){return abs(b-a)<eps;}
bool lt(double a, double b){return !eq(a,b)&&a<b;}
bool gt(double a, double b){return !eq(a,b)&&a>b;}
bool leq(double a, double b){return eq(a,b)||a<b;}
bool geq(double a, double b){return eq(a,b)||a>b;}

double f(double a, double b, double c, double d, double x)
{
  return a*pow(x,3.0)+b*pow(x,2.0)+c*x+d;
}

int xans2dim(double a, double b, double c, double *ans)
{
  double D = b*b - 4*a*c;
  if( lt(D,0) ){
    return 0;
  }else if( gt(D,0) ){
    ans[0]=(-b-sqrt(D))/(2*a);
    ans[1]=(-b+sqrt(D))/(2*a);
    return 2;
  }else{
    ans[0]=-b/(2*a);
    return 1;
  }
}

double det(double a3, double a2, double a1, double a0)
{
  return -4*pow(a1,3.0)*a3+
    pow(a1*a2,2.0)-4*a0*pow(a2,3.0)+
    18*a0*a1*a2*a3-27*pow(a0*a3,2.0);
}

int main()
{
  int N;

  cin >> N;
  for(int tc=0;tc<N;++tc){
    int a,b,c,d;
    int neg_ans = 0, pos_ans = 0;
    
    cin >> a >> b >> c >> d;

    double extreme[2];
    double f0=f(a,b,c,d,0);
    double D=det(a,b,c,d);
    xans2dim(3*a,2*b,c,extreme);
    if(gt(extreme[0],extreme[1]))swap(extreme[0],extreme[1]);

    if( gt(D,0) || eq(D,0) ){
      bool contPos=true;
      bool contNeg=true;

      if(a<0){
	if(leq(extreme[1],0)&&leq(f0,0))contPos=false;
	if(geq(extreme[0],0)&&geq(f0,0))contNeg=false;
      }else if(a>0){
	if(leq(extreme[1],0)&&geq(f0,0))contPos=false;
	if(geq(extreme[0],0)&&leq(f0,0))contNeg=false;
      }
      int M=-d*a;

      if(M<0){
	if(!contPos){
	  neg_ans=3;
	}else{
	  neg_ans=1;
	  pos_ans=2;
	}
      }else if(M>0){
	if(!contNeg){
	  pos_ans=3;
	}else{
	  neg_ans=2;
	  pos_ans=1;
	}
      }else{
	if(gt(extreme[0],0)&&gt(extreme[1],0)){
	  pos_ans=2;
	}else if(lt(extreme[0],0)&&lt(extreme[1],0)){
	  neg_ans=2;
	}else{
	  neg_ans=1;
	  pos_ans=1;
	}
	
	if(eq(D,0)){
	  if(eq(f(a,b,c,d,extreme[0]),0)||eq(f(a,b,c,d,extreme[1]),0)){
	    if(contPos){
	      neg_ans=0;
	      pos_ans=1;
	    }else if(contNeg){
	      neg_ans=1;
	      pos_ans=0;
	    }
	  }
	}
      }

      if( eq(D,0) && eq(-2*pow(b,3.0)+9*a*b*c-27*pow(a,2.0)*d,0) ){
	neg_ans=pos_ans=0;
	if(M<0){
	  neg_ans=3;
	}else if(M>0){
	  pos_ans=3;
	}
      }
      
    }else{
      int M=-d*a;
      if( M < 0 ){
	neg_ans=1;
      }else if( M > 0 ){
	pos_ans=1;
      }
    }

    cout << pos_ans << ' ' << neg_ans << endl;
  }
}