#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int a, b, c, d;

double f(double x) {
    return a * x * x * x + b * x * x + c * x + d;
}

int judge(double x) {
    if(x > 1e-9) return 1;
    if(x < -(1e-9)) return -1;
    return 0;
}

int main() {
    int question;
    cin >> question;
    rep(quest, question) {
        cin >> a >> b >> c >> d;
        if(a < 0) {
            a = -a; b = -b; c = -c; d = -d;
        }
        int de = b * b - 3 * a * c;

        if(de < 0 || de == 0 && 2 * b * b * b - 9 * a * b * c + 27 * a * a * d != 0) {
            if (d > 0) cout << "0 1" << endl;
            else if(d == 0) cout << "0 0" << endl;
            else cout << "1 0" << endl;
        }else if(de == 0) {
            if(d > 0) cout << "0 3" << endl;
            else if(d == 0) cout << "0 0" << endl;
            else cout << "3 0" << endl;
        }else {
            double x1 = (-b - sqrt(de)) / (3 * a);
            double x2 = (-b + sqrt(de)) / (3 * a);
            if(judge(f(x1)) == -1) {
                if(d > 0) cout << "0 1" << endl;
                else if(d == 0) cout << "0 0" << endl;
                else cout << "1 0" << endl;
            }else if(judge(f(x1)) == 0) {
                if(judge(x1) == 1) cout << "3 0" << endl;
                else if(judge(x1) == 0) cout << "1 0" << endl;
                else {
                    if(d > 0) cout << "0 3" << endl;
                    else if(d == 0) cout << "0 2" << endl;
                    else cout << "1 2" << endl;
                }
            }else {
                if(judge(f(x2)) == 1) {
                    if(d > 0) cout << "0 1" << endl;
                    else if(d == 0) cout << "0 0" << endl;
                    else cout << "1 0" << endl;
                }else if(judge(f(x2)) == 0) {
                    if(judge(x2) == -1) cout << "0 3" << endl;
                    else if(judge(x2) == 0) cout << "0 1" << endl;
                    else {
                        if(d > 0) cout << "2 1" << endl;
                        else if(d == 0) cout << "2 0" << endl;
                        else cout << "3 0" << endl;
                    }
                }else {
                    if(judge(x1) == 1) {
                        if(d > 0) cout << "2 1" << endl;
                        else if(d == 0) cout << "2 0" << endl;
                        else cout << "3 0" << endl;
                    }else if(judge(x1 == 0)) cout << "2 0" << endl;
                    else {
                        if(judge(x2) == -1) {
                            if(d > 0) cout << "0 3" << endl;
                            else if(d == 0) cout << "0 2" << endl;
                            else cout << "1 2" << endl;
                        }else if(judge(x2) == 0) cout << "1 2" << endl;
                        else {
                            if(d > 0) cout << "2 1" << endl;
                            else if(d == 0) cout << "1 1" << endl;
                            else cout << "1 2" << endl;
                        }
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 3084