#include #define mp make_pair #define fi first #define se second #define debug(x) cerr<<#x<<" = "<<(x)<void test(T x,Args... args){cerr< pii; typedef pair pll; const int MAXN=(int)1e5+5; const int MOD=(int)1e9+7; int a[MAXN]; int b[MAXN]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t; cin>>t; while(t--){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ cin>>b[i]; } int i=n; while(a[i]==0&&b[i]==0)i--; int g=__gcd(a[i],b[i]); cout<