#include <bits/stdc++.h>
#define int long long
#define debug printf("IAKIOI")
using namespace std;
const int N = 1e5 + 9;
int del(double a, double b, double c) {
double d = b * b - 4 * a * c;
if (d >= 0) return 2;
else return 0;
}
int t, n;
double a, b, c, p, k1, k2, k3;
double d;
double f(double x) {
return a * x * x + b * x + c;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
cin >> a >> b >> c;
cin >> n;
d = 1.0 * -b / 2.0 / a;
for (int i = 1; i <= n; ++i) {
d = 1.0 * -b / 2.0 / a;
cin >> p;
if (p == 1) {
cin >> k1;
c += k1;
}
if (p == 2) {
cin >> k1;
c = a * k1 * k1 - b * k1 + c;
b = -2 * k1 * a + b;
}
if (p == 3) {
cin >> k1 >> k2;
c = -4 * a * k1 * k1 - 2 * b * k1 + 2 * k2 - c;
b = 4 * a * k1 + b;
a = -a;
}
if (p == 4) {
cin >> k1 >> k2;
if (a > 0) {
if (k1 >= d) {
printf("%.2lf %.2lf\n", f(k1), f(k2));
}
else if (k2 <= d) {
printf("%.2lf %.2lf\n", f(k2), f(k1));
}
else {
printf("%.2lf %.2lf\n", f(d), f((k2 - d >= d - k1 ? k1 : k2)));
}
}
else {
if (k1 >= d) {
printf("%.2lf %.2lf\n", f(k2), f(k1));
}
else if (k2 <= d) {
printf("%.2lf %.2lf\n", f(k1), f(k2));
}
else {
printf("%.2lf %.2lf\n", f((k2 - d >= d - k1 ? k2 : k1)), f(d));
}
}
}
if (p == 5) {
cin >> k1 >> k2 >> k3;
printf("%d\n", del(k1 - a, k2 - b, k3 - c));
}
}
printf("%.2lf\n", f(d));
}
return 0;
}