#include using namespace std; const int maxn = 1005; int n; int f[maxn], g[maxn]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int T; for (scanf("%d", &T); 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 k = n - 1; while (f[k] == 0 && g[k] == 0 && k >= 0) --k; if (k < 0) puts("1/0"); else if (g[k] == 0) puts("1/0"); else if (f[k] == 0) puts("0/1"); else { int d = gcd(f[k], g[k]); printf("%d/%d\n", f[k] / d, g[k] / d); } } return 0; }