#include using namespace std; int t; int n; int a[100020]; int b[100020]; int gcd(int x, int y) { return y ? gcd(y, x % y) : x; } int main() { scanf("%d", &t); for (int tt = 0; tt < t; tt++) { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } int na = n; while (a[na - 1] == 0) { na--; } for (int i = 0; i < n; i++) { scanf("%d", &b[i]); } int nb = n; while (b[nb - 1] == 0) { nb--; } if (na == nb) { int A = a[na - 1]; int B = b[nb - 1]; int g = gcd(A, B); A /= g; B /= g; printf("%d/%d\n", A, B); } else if (na > nb) { printf("1/0\n"); } else { printf("0/1\n"); } } }