Under construction

Still being built. Things may change

Random Numbers

Time limit5sMemory limit512 MB

Summary
Given random integers a and a shuffled list b, find m and k so that b is the multiset of (a_i + k) mod m.
Level

Hard8 of 10

Topics
Number theory, Math, Hash map
Solved
No attempts yet

Problem

Yuuka has nn integers a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n, each generated uniformly and independently between 11 and 101810^{18}, inclusive.

Yuuka chooses an integer mm. Next, an integer kk is generated uniformly between 00 and (m−1)(m - 1), inclusive. Then Yuuka changes every a_ia\_i to (a_i+k) mod m(a\_i + k) \bmod m. Finally, she shuffles the integers randomly. The resulting integers are b_1,b_2,…,b_nb\_1, b\_2, \ldots, b\_n.

Given a_1,…,a_na\_1, \dots, a\_n and b_1,…,b_nb\_1, \dots, b\_n, find the values of mm and kk.

Input

The first line contains nn (105≤n≤2⋅10510^5 \le n \le 2 \cdot 10^5).

The second line contains nn integers a_1,…,a_na\_1, \dots, a\_n, randomly generated with 1≤a_i≤10181 \le a\_i \le 10^{18}.

The third line contains nn integers b_1,…,b_nb\_1, \dots, b\_n with 0≤b_i<10100 \le b\_i < 10^{10}.

It is guaranteed that a solution exists with 0≤k<m≤10100 \le k < m \le 10^{10}.

Output

Print mm and kk on a single line. If several answers are possible, print any one of them.

Hint

The example in the statement only shows the format. The system tests do not include it (test 1 is a different test), because it violates the constraints.

Examples1

  1. Example 1

    Input
    10
    1 15 6 4 2 4 6 18 1 20
    6 9 0 9 7 9 0 1 6 3
    
    Expected output
    11 5