Problem: Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere.

One of his birthday presents was a sequence of distinct integers a1, a2, ..., an. Timofey wants to know whether he can rearrange the elements of the sequence so that is will be an arithmetical progression modulo m, or not.

Arithmetical progression modulo m of length n with first element x and difference d is sequence of integers x, x + d, x + 2d, ..., x + (n - 1)·d, each taken modulo m.

Input

The first line contains two integers m and n (2 ≤ m ≤ 109 + 7, 1 ≤ n ≤ 105, m is prime) — Timofey's favorite prime module and the length of the sequence.

The second line contains n distinct integers a1, a2, ..., an (0 ≤ ai < m) — the elements of the sequence.

Output

Print -1 if it is not possible to rearrange the elements of the sequence so that is will be an arithmetical progression modulo m.

Otherwise, print two integers — the first element of the obtained progression x (0 ≤ x < m) and its difference d (0 ≤ d < m).

If there are multiple answers, print any of them.

Examples

Input

17 5
0 2 4 13 15


Output

13 2


Input

17 5
0 2 4 13 14


Output

-1


Input

5 3
1 2 3


Output

3 4

Solution (in PYTHON3):

Solution:
from collections import defaultdict
dic = defaultdict(int)

def pow_mod(a,b,c):
    n = 1
    m = a
    v = b
    if a == 1:
        return 1
    while v > 0:
        if v%2 == 1:
            n *= m%c
            n %= c
        m *= m
        m %= c
        v //= 2
    return n%c

def pow(a,b):
    n = 1
    m = a
    v = b
    if a == 1:
        return 1
    while v > 0:
        if v%2 == 1:
            n *= m
        m *= m
        v //= 2
    return n

def tonelli_shanks(a,p):
    if a == 0:
        return 0
    q = p-1
    s = 0
    while q%2 == 0:
        s += 1
        q //= 2
    z = 2
    while pow_mod(z,(p-1)//2,p) != p-1:
        z += 1
    m = s
    c = pow_mod(z,q,p)
    t = pow_mod(a,q,p)
    r = pow_mod(a,(q+1)//2,p)
    while m > 1:
        if pow_mod(t,pow(2,m-2),p) == 1:
            c = c**2%p
            m -= 1
        else:
            t = (c**2%p)*t%p
            r = c*r%p
            c = c**2%p
            m -= 1
    return r%p

m,n = map(int, input().split())
a = list(map(int, input().split()))
for i in a:
    dic[i] += 1
if n == 1:
    d = 0
    x = a[0]
    print(x,d)
elif n == m-1:
    d = 1
    a.sort()
    if a[0] != (a[-1]+d)%m:
        print(a[0],d)
    for i in range(1,n):
        if a[i] != (a[i-1]+d)%m:
            print(a[i],d)
            quit()
elif n == m:
    d = 1
    x = 0
    print(x,d)
elif m == 2:
    a.sort()
    print(a[0],a[1]-a[0])
elif m == 3:
    a.sort()
    d = a[1]-a[0]
    for i in range(1,n):
        if a[i] != a[i-1]+d:
            print(-1)
            quit()
    print(a[0],d)
else:
    ave = sum(a)*pow_mod(n,m-2,m)%m
    b = [(a[i]-ave)**2%m for i in range(n)]
    s = sum(b)*pow_mod(n,m-2,m)%m
    k = n**2-1
    d2 = s*12*pow_mod(k,m-2,m)%m
    d = tonelli_shanks(d2,m)
    x = (ave-d*(n-1)*pow_mod(2,m-2,m)%m)%m
    if x != int(x):
        print(-1)
        quit()
    x = int(x)
    for i in range(n):
        if not dic[(x+i*d)%m]:
            print(-1)
            quit()
    print(x,d)