#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using ld = long double;
const ld eps = 1e-10;

ld bisectionMethod(ld x0, ld x1, function<ld(ld)> f){
    ld y0 = f(x0), y1 = f(x1);
    int s0 = fabs(y0) < eps ? 0 : y0 < 0 ? -1 : 1;
    int s1 = fabs(y1) < eps ? 0 : y1 < 0 ? -1 : 1;
    assert(s0 * s1 <= 0);
    if(y0 > y1) swap(x0, x1);
    ld m;
    for(int i = 0; i < 200; i++){
        m = (x0 + x1) / 2;
        if(f(m) > 0) x1 = m;
        else x0 = m;
    }
    return m;
}

vector<ld> quadraticEquation(ld a, ld b, ld c){
    ld d = b*b - 4*a*c;
    if(fabs(a) < eps) return fabs(b) > eps ? vector<ld>{ -c/b } : vector<ld>{};
    if(d < -eps) return {};
    dump(d);
    if(d < eps) return { -b / (2*a), -b / (2*a) };
    int sign = (b >= 0) ? 1 : -1;
    ld x1 = (-b - sign * sqrt(abs(d)))/(2.0 * a), x2 = c / (a * x1);
    return { x1, x2 };
}

vector<ld> cubicEquation(ld a, ld b, ld c, ld d){
    if(fabs(a) < eps) return quadraticEquation(b,c,d);
    if(a < 0) a = -a, b = -b, c = -c, d = -d;
    ld x0 = bisectionMethod(-1e8, 1e8, [&](ld x){
            return a*x*x*x + b*x*x + c*x + d;
        });
    ld A = 1, B = b/a + x0, C = c/a + B*x0;
    dump(A,B,C);
    auto res = quadraticEquation(A,B,C);
    dump(res);
    res.push_back(x0);
    sort(res.begin(), res.end());
    // res.erase(unique(res.begin(), res.end(),
    //              [](ld a, ld b){ return fabs(a-b) < eps; }),
    //       res.end());
    return res;
}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        vector<ld> xs = cubicEquation(a,b,c,d);
        int neg = 0, pos = 0;
        for(auto &x : xs) if(x < -eps) ++neg; else if(x > eps) ++pos;
        cout << pos << " " << neg << endl;
    }
}

Measured memory_bytes: 3136