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 (ub <= -EPS || lb >= EPS) return 0;
        foreach (i; 0 .. 100) {
            [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);
            double res = r(-INF, p);
            int plus, minus;
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;
            res = r(p, q);
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;
            res = r(q, INF);
            if (res >= EPS) plus++;
            else if (res <= -EPS) minus++;
            writefln("%d %d", plus, minus);
        }
    }

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