#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repr(i, m, n) for (int i = (int)m; i <= (int)n; i++)
#define repd(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#ifdef LILYWHITE
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) ;
#endif
const int __attribute__((unused)) INF = 0x3f3f3f3f;
template <typename T> inline T rd(T &x) {
x = 0;
T neg = 1;
char c = 0;
while (c < '0' || c > '9') {
if (c == '-')
neg = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - 48;
c = getchar();
}
x *= neg;
return x;
}
template <typename T, typename... Args> inline void rd(T &x, Args &...args) {
rd(x);
rd(args...);
}
int main() {
int T;
rd(T);
while (T--) {
int n;
rd(n);
int unused = 0;
int sum = 1, cnt = 1;
bool flag = 1;
rep(i, n) {
int x;
rd(x);
if (!flag) continue;
if (x == -1) {
if (cnt == 1) {
if (unused) {
// eprintf("Revert \n");
unused--;
sum++;
cnt++;
// eprintf("to %d %d\n", sum, cnt);
continue;
} else {
cout << -1 << endl;
flag = 0;
}
}
cnt--;
} else if (x == 0) {
unused++;
if (cnt == 1) {
unused--;
sum++;
cnt++;
} else {
cnt--;
}
} else {
sum++;
cnt++;
}
// cerr << sum << ' ' << cnt << endl;
}
if (flag) {
cout << sum / gcd(sum, cnt) << ' ' << cnt / gcd(sum, cnt) << endl;
}
}
}