//#include //#pragma GCC optimize(3) #include #include #include #include #include #include #include #include #include #include #include #include //#include #define X first #define Y second #define PB push_back #define MP make_pair #define EB emplace_back #define mset(var,val) memset(var,val,sizeof(var)) #define IOS ios::sync_with_stdio(false);cin.tie(0) #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; typedef long long ll; #ifdef local #define dbg(args...) do { cout << "\033[32;1m" << #args << " -> "; err(args); } while (0) void err() { cout << "\033[39;0m" << endl; } template class T, typename t, typename... Args> void err(T a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); } template void err(T a, Args... args) { cout << a << ' '; err(args...); } #else #define dbg(...) #endif const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos(-1.0); const long double eps = 1e-6; //const int mod = 1e9+7; //const int maxn = 3e6; const int N = 1000+10; const int M = 2e6+10; int _ = 0; void testcase() { cout << "Case " << (++_) << ": "; } template inline bool scan(T&ret) { char c; int sgn; if(c=getchar(),c==EOF) return 0; while(c!='-' and (c<'0' or c>'9')) c=getchar(); sgn=(c=='-')?-1:1; ret=(c=='-')?0:(c-'0'); while(c=getchar(),c>='0' and c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; } template inline void out(T x) { if(x>9) out(x/10); putchar(x%10+'0'); } int a[N],b[N]; int gcd(int a, int b){ return a%b?gcd(b,a%b):b; } void work() { int n; cin >> n; rep(i,n){ cin >> a[i]; } rep(i,n){ cin >> b[i]; } for(int i = n-1; i >= 0; --i){ if(a[i] or b[i]){ int x = a[i], y = b[i]; if(x == 0){ y = 1; } else if(y == 0){ x = 1; } else { int g = gcd(x, y); x /= g; y /= g; } cout << x << "/" << y << "\n"; return; } } } int main() { #ifdef local freopen("../in.txt","r",stdin); // freopen("out.txt","w",stdout); #endif // local IOS; int t; cin >> t; for(;t--;) work(); return 0; }