#1047
Unrated
ZADAĆA
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Ivan Katanić

Mirko has received a homework assignment to compute the greatest common divisor of the two positive integers A and B. Since the numbers are quite large, the teacher provided him with N smaller integers whose product is A, and M integers with product B. Mirko would like to verify his result, so he has asked you to write a program to solve his problem. If the result is more than 9 digits long, output only the last 9 digits.

입력

The first line of input contains the positive integer N (1 ≤ N ≤ 1000). The second line of input contains N space-separated positive integers less than 1 000 000 000, whose product is the number A. The third line of input contains the positive integer M (1 ≤ M ≤ 1000). The fourth line of input contains M space-separated positive integers less than 1 000 000 000, whose product is the number B.

출력

The first and only line of output must contain the greatest common divisor of numbers A and B. If the result is more than 9 digits long, output only the last (least significant) 9 digits.

예제 입력 1

3
2 3 5
2
4 5

예제 출력 1

10

예제 입력 2

4
6 2 3 4
1
1

예제 출력 2

1

예제 입력 3

3
358572 83391967 82
3
50229961 1091444 8863

예제 출력 3

000012028
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.