#include using namespace std; typedef long long LL; typedef pair pii; #ifdef DEBUG #define display(x) cerr << #x << " = " << x << endl; #define displaya(a, st, n)\ {cerr << #a << " = {";\ for(int qwq = (st); qwq <= (n); ++qwq) {\ if(qwq == (st)) cerr << a[qwq];\ else cerr << ", " << a[qwq];\ } cerr << "}" << endl;} #define displayv(v) displaya(v, 0, (int)(v).size() - 1) #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define display(x) ; #define displaya(a, st, n) ; #define displayv(v) ; #define eprintf(...) if(0) fprintf(stderr, "...") #endif template bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; } template bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; } int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); } void solve() { int n; cin >> n; vector f(n), g(n); for(auto &x : f) cin >> x; for(auto &y : g) cin >> y; while(f.back() == 0) f.pop_back(); while(g.back() == 0) g.pop_back(); if(f.size() > g.size()) printf("1/0\n"); else if(f.size() < g.size()) printf("0/1\n"); else { int d = gcd(f.back(), g.back()); printf("%d/%d\n", f.back() / d, g.back() / d); } } int main() { ios::sync_with_stdio(false); int T; cin >> T; while(T--) solve(); return 0; }