#include using namespace std; int test,n,a[1111],b[1111],A,B,d; int gcd(int a,int b) { if (!b) return a; return gcd(b,a%b); } int main() { scanf("%d",&test); while(test--) { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); for (int i=1;i<=n;i++) scanf("%d",&b[i]); for (int i=n;i>=1;i--) { if (a[i]) { A=i; break; } } for (int i=n;i>=1;i--) { if (b[i]) { B=i; break; } } if (AB) printf("1/0\n"); else { d=gcd(a[A],b[B]); printf("%d/%d\n",a[A]/d,b[B]/d); } } return 0; }