signed main() {
int T;
cin >> T;
while (T -- ) {
int a, b, c, d;
cin >> a >> b >> c >> d;
if (a * b < c * d || c * d == 1 && a * b > 1) puts("-1");
else {
int pos = 1;
vector<pair<int, int>> res;
auto work = [&](int t, int k) {
res.emplace_back(t, k);
if (t == 1) {
a /= k;
b *= k;
} else {
a *= k;
b /= k;
}
};
work(1, a);
while (max(a, b) != c * d) {
int k = max(c * d, max(a, b) / 2 + 1);
work(a == 1 ? 2 : 1, k);
}
work(a == 1 ? 2 : 1, a == 1 ? c : d);
cout << res.size() << '\n';
for (auto t : res) cout << t.first << ' ' << t.second << '\n';
}
}
return 0;
}