#include using namespace std; template T gcd(T a,T b){ if(a%b==0)return b; else return gcd(b,a%b); } int main(){ long long S = 1; long long B = 1; int a;cin>>a; for(int i = 0; a > i; i++){ long long t;cin>>t; if(i){ B *= t; }else{ S *= t; } } cin>>a; for(int i = 0; a > i; i++){ long long t;cin>>t; if(i%2){ S *= t; }else{ B *= t; } } if(((S/gcd(S,B) < 0) + (B/gcd(S,B) < 0)) % 2){ cout << "-" << abs(S/gcd(S,B)) << " " << abs(B/gcd(S,B)) << endl; }else{ cout << abs(S/gcd(S,B)) << " " << abs(B/gcd(S,B)) << endl; } }