#include "bits/stdc++.h" using namespace std; int gcd(int a, int b) { //cout << a <<" "<< b << endl; if (b == 0) return a; return gcd(b, a%b); } int main() { int n1,n2; cin >> n1; vector A(n1); int bo=1,si=1; for (int i = 0; i < n1; i++) { cin >> A[i]; if (i == 0) { si *= A[i]; } else { bo *= A[i]; } } cin >> n2; vector B(n2); for (int i = 0; i < n2; i++) { cin >> B[i]; if (i == 0) { bo *= B[i]; } else { si *= B[i]; } } int n=gcd(bo,si); //cout << n << endl; cout << si/n <<" "<< bo/n << endl; }