def func(x,a,b,c,d)
	a * x * x * x + b * x * x + c * x + d
end
n = gets.to_i
n.times{
	
	a,b,c,d = gets.split.map(&:to_f)
	l=-2e9
	r=2e9
	128.times{
		m=(l+r)/2
		v=func(m,a,b,c,d)
		if (v > 0)^(a<0)
			r = m
		else
			l = m
		end
	}
	ans1 = 0
	ans2 = 0
	x=r
	if x > 1e-5
		ans1 += 1
	end

	if x < -1e-5
		ans2 += 1
	end
	
	o = a
	p = a * x + b
	q = p * x + c

	if p*p-4*o*q > -1e-9
		xx = (-p + Math.sqrt(p*p-4*o*q+1e-9)) / (2*o)
		xxx = (-p - Math.sqrt(p*p-4*o*q+1e-9)) / (2*o)
		

		x = xx
		if x > 1e-5

			ans1 += 1
		end

		if x < -1e-5
			ans2 += 1
		end

		x = xxx
		if x > 1e-5
			ans1 += 1
		end

		if x < -1e-5
			ans2 += 1
		end
	end

	printf("%d %d\n",ans1,ans2)
	
}