#P7616. [COCI 2011/2012 #2] ZADAĆA

[COCI 2011/2012 #2] ZADAĆA

Description

Given NN positive integers A1,A2,...,ANA_1, A_2, ..., A_N and MM positive integers B1,B2,...,BMB_1, B_2, ..., B_M, compute:

$$\gcd(\prod\limits_{i=1}^N A_i, \prod\limits_{i=1}^M B_i)$$

Input Format

The first line contains a positive integer NN.

The second line contains NN positive integers AiA_i.

The third line contains a positive integer MM.

The fourth line contains MM positive integers BiB_i.

Output Format

Output one line containing the answer. If the answer has more than nine digits, you only need to output its last nine digits.

3
2 3 5
2
4 5
10
4
6 2 3 4
1
1
1
3
358572 83391967 82
3
50229961 1091444 8863
000012028

Hint

Sample 1 Explanation

gcd(30,20)=10\gcd(30, 20) = 10, so the answer is 1010.

Constraints

For 100%100\% of the testdata, 1N,M10001 \le N, M \le 1000, and 1Ai,Bi1091 \le A_i, B_i \le 10^9.

Notes

The scoring of this problem follows the original COCI problem settings, with a full score of 100100.

This problem is translated from COCI2011-2012 CONTEST #2 T3 ZADAĆA

Translated by ChatGPT 5