#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]; } for ( int i = 1; i < n1; i++ ) { B[0] *= A[i]; } for ( int i = n2-1; i > 1; i-- ) { B[i-2] *= B[i]; } long long a,b; a = A[0] * ( n2 == 1 ? 1 : B[1] ); b = B[0]; 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; }