#include using namespace std; int gcd(int a,int b){ int r; while((r=a%b) != 0){ a = b; b = r; } return b; } int main(){ //input int numerator_num; cin >> numerator_num; int num_comp[numerator_num]; for(int i=0;i> num_comp[i]; } int denominator_num; cin >> denominator_num; int den_comp[denominator_num]; for(int i=0;i> den_comp[i]; } int output_numerator = 1; int output_denominator = 1; for(int i=numerator_num-1;i>0;i--){ output_denominator *= num_comp[i]; } output_numerator *= num_comp[0]; for(int i=denominator_num-1;i>0;i--){ output_numerator *= den_comp[i]; } output_denominator *= den_comp[0]; int GCD = gcd(output_numerator,output_denominator); cout << output_numerator/abs(GCD) << " " << output_denominator/abs(GCD) << endl; return 0; }