#include<iostream>
#include<cmath>
using namespace std;

const double eps = 1e-9;

int main() {
  int n;
  double p,q,r,s;
  cin>>n;

  while(n--) {
    cin>>p>>q>>r>>s;
    double a = q/p,b = r/p,c = s/p;
    double d = a,e = b,alpha = 0.0;
    if(abs(c) > eps) {
      double low = -1000000000,hi = 1000000000;
      for(int i=0; i<200; ++i) {
    double mid = (low+hi)/2.0;
    if(mid*mid*mid+a*mid*mid+b*mid+c < 0) low = mid;
    else hi = mid;
      }
      alpha = low;
      d = a+alpha, e = -c/alpha;
    }

    double han = d*d - 4.0*e;
    double s1 = 0.0,s2 = 0.0;
    if(han > -eps) {
      if(han < 0.0) han = 0.0;
      s1 = 0.5*(-d + sqrt(han));
      s2 = 0.5*(-d - sqrt(han));
    }
    //cout<<alpha<<" "<<s1<<" "<<s2<<" "<<d<<" "<<e<<" "<<han<<endl;
    int ps = 0, ns = 0;
    if(alpha > eps) ps++;
    if(alpha < -eps) ns++;
    if(s1 > eps) ps++;
    if(s1 < -eps) ns++;
    if(s2 > eps) ps++;
    if(s2 < -eps) ns++;
    cout<<ps<<" "<<ns<<endl;
  }
}