#include #include #include using namespace std; typedef long long ll; int gcd(int x, int y) {return !y ? x : gcd(y, x % y);} void Do() { int n; scanf("%d", &n); int a = 0, ta = -1, b = 0, tb = -1; for(int i = 0; i < n; i++) { int x; scanf("%d", &x); if(x) a = x, ta = i; } for(int i = 0; i < n; i++) { int x; scanf("%d", &x); if(x) b = x, tb = i; } if(b == 0 || ta > tb) puts("1/0"); else { if(ta < tb) a = 0; int g = gcd(a, b); a /= g, b /= g; printf("%d/%d\n", a, b); } } int main() { int T; scanf("%d", &T); while(T--) { Do(); } }