#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const long double EPS = 1e-9;
const long double INF = 1LL<<60;
//const frac EPS = 0;

template<class T> struct Polynomial : vector<T> {
    Polynomial() : vector<T>(1, 0) { }
    Polynomial(T num) : vector<T>(1, num) { }
    Polynomial(int size, T num) : vector<T>(size, num) { }
    Polynomial(vector<T> vec) { *this = vec; }
    
    Polynomial<T>& normalize() {
        while ( (*this).size() > 1 && abs((*this).back()) <= EPS ) (*this).pop_back();
        return (*this);
    }
    T sub(T x) {
        T res = 0;
        for (int i =  (*this).size()-1; i > 0; --i) res = res + (*this)[i], res = res * x;
        res += (*this)[0];
        return res;
    }
    inline Polynomial<T> operator - () { 
        for (int i = 0; i < (*this).size(); ++i) (*this)[i] = (*this)[i] * (-1); 
        return (*this);
    }
    inline const Polynomial<T>& operator += (const Polynomial<T> &x);
    inline const Polynomial<T>& operator -= (const Polynomial<T> &x);
    inline const Polynomial<T>& operator *= (T x);
    inline const Polynomial<T>& operator *= (const Polynomial<T> &x);
    inline const Polynomial<T>& operator /= (T x);
    inline const Polynomial<T>& operator /= (const Polynomial<T> &x);
    inline const Polynomial<T>& operator %= (T x);
    inline const Polynomial<T>& operator %= (const Polynomial<T> &x);
};

template<class T> inline bool operator > (Polynomial<T> x, Polynomial<T> y) { return x.size() > y.size(); }
template<class T> inline bool operator < (Polynomial<T> x, Polynomial<T> y) { return y > x; }
template<class T> inline bool operator <= (Polynomial<T> x, Polynomial<T> y) { return !(y < x); }
template<class T> inline bool operator >= (Polynomial<T> x, Polynomial<T> y) { return !(x < y); }
template<class T> inline bool operator != (Polynomial<T> x, Polynomial<T> y) { return x < y || y < x; }
template<class T> inline bool operator == (Polynomial<T> x, Polynomial<T> y) { return !(x < y) && !(y < x); }

template<class T> ostream &operator << (ostream &os, Polynomial<T> x) {
    for (int i = x.size()-1; i >= 0; --i) { 
        if (i != x.size()-1) os << abs(x[i]); else os << x[i];
        if (i != 0) {
            os << "x"; if (i != 1) os << "^" << i; os << " ";
            if (x[i-1] < 0) os << "- "; else os << "+ ";
        }
    }
    return os;
}

template<class T> inline Polynomial<T> operator + (Polynomial<T> x, Polynomial<T> y) {
    while (x.size() > y.size()) y.push_back(0);
    while (y.size() > x.size()) x.push_back(0);
    Polynomial<T> z((int)x.size(), 0);
    for (int i = 0; i < x.size(); ++i) z[i] = x[i] + y[i];
    return z.normalize();
} 
template<class T> inline Polynomial<T> operator - (Polynomial<T> x, Polynomial<T> y) {
    y = -y;
    return x + y;
}
template<class T> inline Polynomial<T> operator * (Polynomial<T> x, T a) {
    Polynomial<T> z((int)x.size(), 0);
    for (int i = 0; i < x.size(); ++i) z[i] = x[i] * a;
    return z.normalize();
}
template<class T> inline Polynomial<T> operator * (Polynomial<T> x, Polynomial<T> y) {
    Polynomial<T> z((int)x.size() + (int)y.size() - 1, 0);
    for (int i = 0; i < x.size(); ++i) for (int j = 0; j < y.size(); ++j) z[i+j] = z[i+j] + x[i] * y[j];
    return z.normalize();
}
template<class T> pair<Polynomial<T>,T> divmod(Polynomial<T> x, T a) {
    for (int i = x.size()-1; i >= 0; --i) x[i] = x[i] / a;
    x.normalize();
    return pair<Polynomial<T>,T>(x, 0);
}
template<class T> Polynomial<T> operator / (Polynomial<T> x, T a) {
    return divmod(x, a).first;
}
template<class T> T operator % (Polynomial<T> x, T a) {
    return divmod(x, a).second;
}
template<class T> pair<Polynomial<T>, Polynomial<T> > divmod(Polynomial<T> x, Polynomial<T> y) {
    if (x.size() < y.size()) return make_pair(0, x);
    Polynomial<T> q((int)x.size() - (int)y.size() + 1, 0);
    for (int i = x.size()-1; i >= y.size()-1; --i) {
        T div = x[i] / y.back();
        q[i-(int)y.size()+1] = div;
        for (int j = 0; j < y.size(); ++j) x[i+j-(int)y.size()+1] = x[i+j-(int)y.size()+1] - y[j] * div;
    }
    return make_pair(q, x.normalize());
}
template<class T> Polynomial<T> operator / (Polynomial<T> x, Polynomial<T> y) {
    return divmod(x, y).first;
}
template<class T> Polynomial<T> operator % (Polynomial<T> x, Polynomial<T> y) {
    return divmod(x, y).second;
}
template<class T> inline Polynomial<T> pow(Polynomial<T> a, T n) {
    Polynomial<T> res = 1;
    while (n > 0) { if (n & 1) { res = res * a; } a = a * a; n >>= 1; }
    return res;
}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator += (const Polynomial<T> &x) {*this = *this + x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator -= (const Polynomial<T> &x) {*this = *this - x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator *= (T x) {*this = *this * x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator *= (const Polynomial<T> &x) {*this = *this * x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator /= (T x) {*this = *this / x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator /= (const Polynomial<T> &x) {*this = *this / x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator %= (T x) {*this = *this % x; return *this;}
template<class T> inline const Polynomial<T>& Polynomial<T>::operator %= (const Polynomial<T> &x) {*this = *this % x; return *this;}



vector<long double> quad_eq(long double a, long double b, long double c) {
    vector<long double> res;
    if (abs(a) < EPS) {
        if (abs(b) < EPS) {
            if (abs(c) < EPS) return res;               // all real numbers
            else return res;                            // no solutions
        }
        else return vector<long double>(1, -c/b);
    }
    long double D = b*b - a*c*4;
    if (D > EPS) {
        res.push_back( (-b+sqrt(D))/(a*2) );
        res.push_back( (-b-sqrt(D))/(a*2) );
        return res;
    }
    else if (abs(D) <= EPS) {
        return vector<long double>(2, -b/(a*2));
        //return vector<long double>(1, -b/(a*2));
    }
    else return res;
}



int NUM;


int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    
    cin >> NUM;
    for (int iii = 0; iii < NUM; ++iii) {
        int sei = 0, hu = 0;
        
        Polynomial<long double> pol(4, 0);
        cin >> pol[3] >> pol[2] >> pol[1] >> pol[0];
        if (pol[3] < 0) for (int i = 0; i < 4; ++i) pol[i] = -pol[i];
        
        long double lo = -INF, hi = INF;
        for (int i = 0; i < 100; ++i) {
            long double med = (lo + hi) / 2;
            long double val = pol.sub(med);
            if (val > 0) hi = med;
            else lo = med;
        }
         
        if (lo > 1e-5) ++sei;
        else if (lo < -1e-5) ++hu;
        
        Polynomial<long double> insuu(2, 0);
        insuu[0] = -lo;
        insuu[1] = 1.0;
        
        Polynomial<long double> shou = pol / insuu;
        vector<long double> kai = quad_eq(shou[2], shou[1], shou[0]);
        
        for (int i = 0; i < kai.size(); ++i) {
            if (kai[i] > 1e-5) ++sei;
            else if (kai[i] < -1e-5) ++hu;
        }
        
//        cout << endl;
//        COUT(pol);
//        COUT(lo);
//        COUT(insuu);
//        COUT(shou);
//        COUT(pol % insuu);
//        COUT(kai);
        
        cout << sei << " " << hu << endl;
    }
    return 0;
}


Measured memory_bytes: 1256