#include using namespace std; #define LL long long #define lowbit(x) ((x) & -(x)) #define lson l,mid,id<<1 #define rson mid+1,r,id<<1|1 #define MID(l, r) (((l)+(r))>>1) const int maxn = (int) 1e5 + 20; const int MOD = 1e9 + 7; //const int MOD = 998244353; template < typename T > inline void read(T &x) { static bool f; static char ch; f = 0; x = 0; ch = getchar(); while(ch < '0' || '9' < ch) {if(ch == '-') f = 1; ch = getchar();} while('0' <= ch && ch <= '9') {x = (x << 3) + (x << 1) + (ch - '0'); ch = getchar();} if(f) x = -x; } LL fp(LL a, LL n, LL m = MOD) { LL res = 1; while(n) { if(n & 1) res = res * a % m; a = a * a % m; n >>= 1; } return res; } LL gcd(LL a, LL b) { if(!b) return a; return gcd(b, a % b); } int n; int a[100005], b[100005]; void work() { cin >>n; for(int i = 0; i < n; i++) cin >>a[i]; for(int i = 0; i < n; i++) cin >>b[i]; int i; for(i = n - 1; i; i--) { if(a[i] || b[i]) break; } int p = a[i], q = b[i]; int g = gcd(p, q); p /= g; q /= g; cout <

>tc; for(int ca = 1; ca <= tc; ca++) { // printf("Case #%d: ", ca); work(); } return 0; }