Area

시간 제한1초메모리 제한2048 MB

요약
N×N 격자에서 두 대각선 위 칸들의 넓이가 주어질 때, 질의한 칸의 넓이를 구해 소인수분해 형태로 출력한다.
난이도

어려움10점 중 8점

유형
정수론, 수학, 구현
정답자
아직 제출이 없습니다

문제

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

The plots located at the intersection of the ii-th column and the ii-th row (for 1≤i≤N1 \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 1≤i≤N−11 \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 (2≤N≤1,0002 \le N \le 1\\,000).

The second line contains NN integers A_1,A_2,…,A_NA\_1, A\_2, \dots, A\_N (1≤A_i≤1091 \le A\_i \le 10^9) --- the areas of the plots on the long diagonal.

The third line contains N−1N-1 integers B_1,B_2,…,B_N−1B\_1, B\_2, \dots, B\_{N-1} (1≤B_i≤1091 \le B\_i \le 10^9) --- the areas of the plots on the short diagonal.

The fourth line contains two integers XX and YY (1≤X,Y≤N1 \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 P_iP\_i and S_iS\_i. The numbers P_iP\_i must be distinct primes. The numbers S_iS\_i must be non-zero integers such that S=P_1S_1⋅P_2S_2⋅P_3S_3⋅…⋅P_kS_k,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 P_iP\_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".

예제3

  1. 예제 1

    입력
    5
    6 1 3 9 5
    3 9 3 6
    2 3
    
    예상 출력
    3 -1
    
  2. 예제 2

    입력
    5
    5 2 8 3 5
    2 6 8 9
    5 2
    
    예상 출력
    2 1
    3 2
    
  3. 예제 3

    입력
    5
    6 1 3 9 5
    3 9 3 6
    2 4
    
    예상 출력
    1 1