#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],b[N],n,T;
void solve() {
	cin>>n;
  	int A = 0, B = 0;
  	for(int i=0;i<n;++i) {
    scanf("%d", &a[i]);
    if(a[i])A=i;
  }
  for(int i=0;i<n;++i) {
    scanf("%d",&b[i]);
    if(b[i])B=i;
  }
  if(A<B)puts("0/1");
  else if (A == B){
    A=a[A],B=b[B];
    int f=__gcd(A,B);
    A/=f,B/=f,printf("%d/%d\n", A, B); 
  }
  else puts("1/0");
}
int main(){
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  scanf("%d", &T);
  for(;T;--T)solve();
  return 0;
}