Under construction

Still being built. Things may change

Area

Time limit1sMemory limit2048 MB

Summary
Given the areas of the long and short diagonal plots in an N by N grid, find the area of the plot at column X, row Y as a prime factorization.
Level

Medium5 of 10

Topics
Math, Number theory
Solved
No attempts yet

Problem

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 are numbered 1…N1 \ldots N from left to right, as shown in the figures below. The figures are not to scale.

The plots at the intersection of the ii-th column and the ii-th row (1≤i≤N1 \le i \le N) form the long diagonal. The plots at the intersection of the (i+1)(i+1)-st column and the ii-th row (1≤i≤N−11 \le i \le N-1) form the short diagonal.

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

Input

The first line contains an integer NN (2≤N≤1 0002 \le N \le 1\,000).

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

The third line contains N−1N-1 integers B1,B2,…,BN−1B_1, B_2, \dots, B_{N-1} (1≤Bi≤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 you need.

Output

Let SS be the area of the plot. Print SS as a list of lines, each with two integers PiP_i and SiS_i. Each PiP_i is a distinct prime, and each SiS_i is a non-zero integer, such that S=P1S1⋅P2S2⋅…⋅PkSkS = P_1^{S_1} \cdot P_2^{S_2} \cdot \ldots \cdot P_k^{S_k}, where kk is the number of lines. List the lines in increasing order of PiP_i.

If S=1S = 1, print a single line "1 1".

Examples3

  1. Example 1

    Input
    5
    6 1 3 9 5
    3 9 3 6
    2 3
    
    Expected output
    3 -1
    
  2. Example 2

    Input
    5
    5 2 8 3 5
    2 6 8 9
    5 2
    
    Expected output
    2 1
    3 2
    
  3. Example 3

    Input
    5
    6 1 3 9 5
    3 9 3 6
    2 4
    
    Expected output
    1 1