#include using namespace std; int main() { int num; int molecule = 1; int denominator = 1; cin >> num; // 分子の数を読み込む int i,tmp; for (i = 0; i < num; i++) { cin >> tmp; if (i % 2 == 0) { molecule *= tmp; }else{ denominator *= tmp; } } cin >> num; // 分母の数を読み込む for (i = 0; i < num; i++) { cin >> tmp; if(i % 2 == 0) { denominator *= tmp; }else{ molecule *= tmp; } } // 大きい方の値を求める int bigNum; if (molecule > denominator) { bigNum = molecule; }else{ bigNum = denominator; } // 既約分数を求める for (i = 1; i < bigNum; i++) { if (denominator % i == 0 && molecule % i == 0) { denominator /= i; molecule /= i; } } cout << molecule << " " << denominator << endl; return 0; }