#include #include using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++) #define revrep(i,n) for(int (i)=(n)-1;i>=0; i--) ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; } pair rec(vector& a, int s, int n) { if(s==n-1) return make_pair(a[s],1LL); ll u,l; tie(u,l) = rec(a,s+1,n); return make_pair(a[s]*l,u); } int main() { cin.tie(0); ios::sync_with_stdio(false); cout<::max_digits10); int n1; cin>>n1; vector a(n1); rep(i,n1)cin>>a[i]; int n2; cin>>n2; vector b(n2); rep(i,n2)cin>>b[i]; ll au,al; au = a[0]; al = 1; repeat(i,1,n1) { al*=a[i]; } ll bu,bl; bu=b[0]; bl=1; repeat(i,1,n2) bl*=b[i]; ll U = au*bl; ll L = al*bu; if(L<0) { U*=-1; L*=-1; } ll g = gcd(abs(U),abs(L)); //cout << U << " " << L << " " << g<< endl; cout << U/g << " " << L/g << endl; return 0; }