#include using namespace std; int main() { int T; int n; int *p1, *p2; int now; bool f = false; cin >> T; for (int i = 0; i < T; i++) { cin >> n; p1 = (int*)malloc(sizeof(int)*n); p2 = (int*)malloc(sizeof(int)*n); f = false; now = n - 1; for (int i = 0; i < n; i++) cin >> p1[i]; for (int i = 0; i < n; i++) cin >> p2[i]; while (!f) { if (p1[now] != 0 && p2[now] != 0) { int temp, r; int a = p1[now]; int b = p2[now]; if (a < b) { temp = a; a = b; b = temp; } while (b != 0) { r = a%b; a = b; b = r; } cout << p1[now]/a << "/" << p2[now]/a << endl; f = true; } if (p1[now] == 0 && p2[now] != 0) { cout << "0/1" << endl; f = true; } if (p1[now] != 0 && p2[now] == 0) { cout << "1/0" << endl; f = true; } now--; } } return 0; }