#include "bits/stdc++.h" using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(int)(n);i++) int gcd(ll a,ll b){return b?gcd(b,a%b):a;} int gcd(int a,int b){return b?gcd(b,a%b):a;} #define MOD 1000000007 int main() { cin.tie(0); ios::sync_with_stdio(false); ll n,a,b=1,c,g; bool m=false; cin >> n; cin >> a; if(a<0) { a=-a; m^=true; } rep(i,n-1) { cin >> c; b*=c; if(b<0) { b=-b; m^=true; } } cin >> n; rep(i,n) { cin >> c; if (i%2==1) { a*=c; if(a<0) { a=-a; m^=true; } } else { b*=c; if(b<0) { b=-b; m^=true; } } } g=gcd(a,b); a/=g; b/=g; if (m) { a=-a; } cout << a << " " << b << endl; return 0; }