#include using namespace std; #define int long long const int MOD=1000000007; const int INF=1e18; int gcd(int x,int y){if(x==0)return y;return gcd(y%x,x);} int lcm(int x, int y){return(x*y/gcd(x, y));} signed main(){ cin.tie(0); ios::sync_with_stdio(false); int A = 1,B = 1; int cnt = 0; int N,x; cin >> N ; for(int i = 0 ; i < N ; i++){ cin >> x ; if (x<0) { cnt++; } if (i==0) { A*=x; } else { B*=x; } } int M; cin >> M ; for(int i = 0 ; i < M ; i++){ cin >> x ; if (x<0) { cnt++; } if (i%2==0) { B*=x; } else { A*=x; } } x=gcd(abs(A),abs(B)); cout << abs(A)/x*(pow(-1,(cnt%2))) <<" " <