#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #define fi first #define se second #define endl '\n' #define o2(x) (x)*(x) #define BASE_MAX 62 #define mk make_pair #define eb emplace_back #define all(x) (x).begin(), (x).end() #define clr(a,b) memset((a),(b),sizeof((a))) #define iis std::ios::sync_with_stdio(false); cin.tie(0) #define my_unique(x) sort(all(x)),x.erase(unique(all(x)),x.end()) using namespace std; #pragma optimize("-O3") typedef long long LL; typedef pair pii; typedef pair pLi; inline LL read(){ LL x=0;int f=0;char ch=getchar(); while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar(); while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar(); return x=f?-x:x; } inline void write(LL x) { if(x==0){putchar('0'),putchar('\n');return;} if(x < 0) {putchar('-');x=-x;} static char s[23];int l = 0; while(x!=0)s[l++]=x%10+48,x/=10; while(l)putchar(s[--l]); putchar('\n'); } int lowbit(int x) {return x&(-x);} template T big(const T& a1,const T& a2) { return a1>a2?a1:a2; } template T big (const T& f,const R& ...r) { return big(f, big (r...)); } template T sml(const T& a1,const T& a2) { return a1 T sml (const T& f,const R& ...r) { return sml(f, sml (r...)); } void debug_out() { cerr << '\n'; } template void debug_out (const T& f,const R& ...r) { cerr << f << " "; debug_out (r...); } #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__); #define print(x) write(x); const LL INFLL = 0x3f3f3f3f3f3f3f3fLL; const int HMOD[] = {1000000009, 1004535809}; const LL BASE[] = {1572872831, 1971536491}; const int mod = 1e9 + 6; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const int MXN = 1e6 + 7; int n, m; int ar[MXN], br[MXN]; int main() { int tim = read(); while(tim --) { n = read(); int x = 1, y = 1; for(int i = 1; i <= n; ++i) ar[i] = read(); for(int i = 1; i <= n; ++i) br[i] = read(); for(int i = n; i >= 1; --i) { if(ar[i]) { x = i; break; } } for(int i = n; i >= 1; --i) { if(br[i]) { y = i; break; } } if(x == y) { int z = __gcd(ar[x], br[y]); printf("%d/%d\n", ar[x]/z, br[y]/z); }else if(x > y) printf("1/0\n"); else printf("0/1\n"); } return 0; }