#include #include using namespace std; //最大公約数 int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main(int argc, char* argv[]) { int i,n1,n2; cin>>n1; int A,B; int A1; cin>>A1; int A2=1; for (i=2;i<=n1;i++){ cin>>A; A2*=A; } if (A1<0&&A2<0){ A1=-A1; A2=-A2; } if (A1>0 && A2<0){ A1=-A1; A2=-A2; } cin>>n2; int B1; cin>>B1; int B2=1; for (i=2;i<=n2;i++){ cin>>B; B2*=B; } if (B1<0&&B2<0){ B1=-B1; B2=-B2; } if (B1>0 && B2<0){ B1=-B1; B2=-B2; } int A3=A1*B2; int B3=A2*B1; int A4=A3; if (A4<0){ A4=-A4; } int B4=B3; if (B4<0){ B4=-B4; } int C=gcd(A4,B4); cout<