#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; long long gcd( long long a, long long b ) { if ( b == 0 ) { return a; } return gcd( b, a%b ); } int main() { int n1,n2; cin >> n1; vector A(n1); for ( int i = 0; i < n1; i++ ) { cin >> A[i]; } cin >> n2; vector B(n2); for ( int i = 0; i < n2; i++ ) { cin >> B[i]; } long long a,b; a = A[0]; b = B[0]; for ( int i = 1; i < n2; i++ ) { a *= B[i]; } for ( int i = 1; i < n1; i++ ) { b *= A[i]; } long long g = gcd( abs(a), abs(b) ); a /= g; b /= g; if ( a > 0 != b > 0 ) { cout << -abs(a) << " " << abs(b) << endl; } else { cout << abs(a) << " " << abs(b) << endl; } return 0; }