#include #include using namespace std; const int N = 1000 + 10; int n; int f[N], g[N]; int main(){ int T; scanf("%d", &T); while(T --){ scanf("%d", &n); for(int i = 0; i < n; ++ i){ scanf("%d", &f[i]); } for(int i = 0; i < n; ++ i){ scanf("%d", &g[i]); } int p = -1; int q = -1; int f1 = -1; for(int i = n-1; i >= 0; -- i){ if(f[i] == 0 && g[i] == 0){ continue; } if(f[i] == 0){ f1 = 0; break; } if(g[i] == 0){ f1 = 1; break; } p = f[i]; q = g[i]; break; } if(p == -1){ if(f1 == 0){ printf("0/1\n"); } else if(f1 == 1){ printf("1/0\n"); } else{ printf("0/1\n"); } } else{ int g = __gcd(p, q); printf("%d/%d\n", p/g, q/g); } } }