import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const EPS = 1e-10;
const INF = 1e4;

bool EQ(double x, double y) {
    return abs(y - x) <= EPS;
}
 
void main() {

    int a, b, c, d;
    void input() {
        scanf("%d %d %d %d\n", &a, &b, &c, &d);
    }

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

    double r(double lb, double ub) {
        if (f(ub) <= -EPS || f(lb) >= EPS) return 0;
        version(Debug) { writeln("r: ", [lb, ub]); }
        foreach (i; 0 .. 100) {
            double mid = (lb + ub) / 2;
            (f(mid) < 0 ? lb : ub) = mid;
        }
        return lb;
    }

    double r1(double lb, double ub) {
        // [lb, ub]で単調減少
        if (f(lb) <= -EPS || f(ub) >= EPS) return 0;
        version(Debug) { writeln("r1: ", [lb, ub]); }
        foreach (i; 0 .. 100) {
            version(Debug) {[lb, ub].writeln;}
            double mid = (lb + ub) / 2;
            (f(mid) > 0 ? lb : ub) = mid;
        }
        return lb;
    }



    void solve() {
        if (a < 0) {
            a *= -1; b *= -1; c *= -1; d *= -1;
        }
        double D = b * b - 3 * a * c;
        void A1() {
            // 単調増加, 重解なし
            double res = r(-INF, INF);
            if (res >= EPS) {
                writeln("1 0");
            } else if (res <= -EPS) {
                writeln("0 1");
            } else {
                writeln("0 0");
            }
        }
        if (D < 0) { 
            A1;
        } else if (D == 0) {
            double x = -b / (3 * a);
            if (EQ(f(x), 0)) {
                // 3重解を持つ
                if (x > 0) {
                    writeln("3 0");
                } else if (x < 0) {
                    writeln("0 3");
                } else {
                    writeln("0 0");
                }
            } else {
                A1();
            }
        } else {
            double p = (-b - sqrt(D)) / (3 * a),
                   q = (-b + sqrt(D)) / (3 * a);
            version(Debug) {writeln("[p, q]: ", [p, q]);}
            double res = r(-INF, p);
            version(Debug) { writeln("res1: ", res); }
            int plus, minus;
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;
            res = r1(p, q);
            version(Debug) { writeln("res2: ", res); }
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;
            res = r(q, INF);
            version(Debug) { writeln("res3: ", res); }
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;

            //writeln([plus, minus]);
            /*
            if (f(p).EQ(0)) {
                (p > 0 ? plus : minus)++;
            }
            if (f(q).EQ(0)) {
                (q > 0 ? plus : minus)++;
            }
            */
            writefln("%d %d", plus, minus);
        }
    }

    int T; scanf("%d\n", &T);
    foreach (t; 0 .. T) {
        input; solve;
    }
}

Measured memory_bytes: 1088