Area | 프로그래밍의 벗 PivotOJ
PivotOJ

Area

시간 제한: 1000ms메모리 제한: 2048MB출처: EIO 2023-24 sel1BOJ 32976
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

A square field has been divided into N2N^2 rectangular plots by drawing (N1)(N-1) vertical and (N1)(N-1) horizontal lines. The rows of plots are numbered 1N1 \ldots N from bottom to top and the columns 1N1 \ldots N from left to right, as shown on the figures below (the figures are not to scale).

[이미지 1]

The plots located at the intersection of the ii-th column and the ii-th row (for 1iN1 \le i \le N) are called the long diagonal. The plots located at the intersection of the (i+1)(i+1)-st column and the ii-th row (for 1iN11 \le i \le N-1) are called the short diagonal.

You know the areas of the plots on the long and short diagonals. Calculate the area of the plot at the intersection of the XX-th column and the YY-th row.

입력

The first line contains the integer NN (2N10002 \le N \le 1\,000).

The second line contains NN integers A1,A2,,ANA_1, A_2, \dots, A_N (1Ai1091 \le A_i \le 10^9) --- the areas of the plots on the long diagonal.

The third line contains N1N-1 integers B1,B2,,BN1B_1, B_2, \dots, B_{N-1} (1Bi1091 \le B_i \le 10^9) --- the areas of the plots on the short diagonal.

The fourth line contains two integers XX and YY (1X,YN1 \le X, Y \le N) --- the coordinates of the plot whose area should be calculated.

출력

Output the area SS of the plot located at the intersection of the XX-th column and the YY-th row. The answer should be represented as a sequence of lines, each containing two integers PiP_i and SiS_i. The numbers PiP_i must be distinct primes. The numbers SiS_i must be non-zero integers such that S=P1S1P2S2P3S3PkSk, S = P_1^{S_1} \cdot P_2^{S_2} \cdot P_3^{S_3} \cdot \ldots \cdot P_k^{S_k}, where kk is the number of lines in the answer. The lines must be listed in increasing order of PiP_i. (Recall that an integer PP is considered prime if it has exactly two positive integer divisors: 11 and PP.)

If S=1S = 1, then output it as a single line "1 1".

예제

예제 1

입력
5
6 1 3 9 5
3 9 3 6
2 3
출력
3 -1

예제 2

입력
5
5 2 8 3 5
2 6 8 9
5 2
출력
2 1
3 2

예제 3

입력
5
6 1 3 9 5
3 9 3 6
2 4
출력
1 1
코드를 제출하려면 로그인하세요.