#include #define ll long long #define N 2005 using namespace std; int T,n,f[N],g[N]; int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&f[i]); for(int i=1;i<=n;i++) scanf("%d",&g[i]); int p1=n,p2=n; while(f[p1]==0) p1--; while(g[p2]==0) p2--; if(p1>p2) printf("1/0\n"); else if(p2>p1) printf("0/1\n"); else printf("%d/%d\n",f[p1]/__gcd(f[p1],g[p2]),g[p2]/__gcd(f[p1],g[p2])); } }