#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define f first
#define s second
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int t; cin >> t;
while (t--){
int n;
cin >> n;
int total = 1;
vector<int> ones;
vector<int> zeros;
vector<int> negs;
for(int i = 0; i < n; i++){
int a;
cin >> a;
if(a == 1){
total++;
ones.pb(i);
}else if(a == 0){
zeros.pb(i);
}else{
negs.pb(i);
}
}
vector<pii> vec;
int ind = 0;
for(int i = 0; i < ones.size(); i++){
while(ind < negs.size() && negs[ind] <= ones[i]){
ind++;
}
if(ind == negs.size()) break;
ones[i] = -1;
negs[ind] = -1;
}
int givens = 0;
int combines = 0;
for(int i = 0; i < ones.size(); i++){
if(ones[i] == -1) continue;
vec.pb({ones[i], 1});
}
for(int i = 0; i < negs.size(); i++){
if(negs[i] == -1) continue;
vec.pb({negs[i], -1});
combines++;
}
for(int i = 0; i < zeros.size(); i++){
vec.pb({zeros[i], 0});
}
sort(vec.begin(), vec.end());
/*
for(int i = 0; i < vec.size(); i++){
cout << vec[i].s << " ";
}
cout << "\n";
*/
bool works = true;
for(int i = 0; i < vec.size(); i++){
if(vec[i].s == 1) givens++;
else if(vec[i].s == -1){
givens--;
combines--;
}else{
if(givens > combines) givens--;
else{
givens++;
total++;
}
}
if(givens < 0) works = false;
}
if(works){
int g = __gcd(total, givens+1);
cout << total/g << " " << (givens+1)/g << "\n";
}else{
cout << -1 << "\n";
}
}
cout << endl;
}