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 CPP):

Solution:
#include <bits/stdc++.h>
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
long long power(long long a, long long r, long long mod) {
  if (r == 0) return 1;
  if (r == 1) return a;
  long long res = power(a, r / 2, mod);
  res = res * res % mod;
  if (r & 1) res = res * a % mod;
  return res;
}
long long legendre(long long a, long long mod) {
  return power(a, (mod - 1) / 2, mod);
}
std::pair<long long, long long> multiply_Fp2(std::pair<long long, long long> a,
                                             std::pair<long long, long long> b,
                                             long long omega, long long mod) {
  long long Re =
      (a.first * b.first + (a.second * b.second % mod) * omega) % mod;
  long long Im = (a.first * b.second + a.second * b.first) % mod;
  return std::make_pair(Re, Im);
}
std::pair<long long, long long> power_Fp2(std::pair<long long, long long> a,
                                          long long r, long long omega,
                                          long long mod) {
  if (r == 0) return std::make_pair(1, 0);
  if (r == 1) return a;
  std::pair<long long, long long> res = power_Fp2(a, r / 2, omega, mod);
  res = multiply_Fp2(res, res, omega, mod);
  if (r & 1) res = multiply_Fp2(res, a, omega, mod);
  return res;
}
long long root(long long x2, long long mod) {
  for (;;) {
    long long a = rng() % (mod - 1) + 1;
    long long w2 = (a * a - x2 + mod) % mod;
    if (legendre(w2, mod) != mod - 1) continue;
    std::pair<long long, long long> res =
        power_Fp2(std::make_pair(a, 1), (mod + 1) / 2, w2, mod);
    return res.first;
  }
}
long long n, m;
long long a[100010];
long long S1, S2;
long long d, x;
std::vector<long long> test;
int main() {
  scanf("%I64d%I64d", &m, &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    S1 = (S1 + a[i]) % m;
    S2 = (S2 + a[i] * a[i]) % m;
  }
  std::sort(a, a + n);
  if (n > m)
    printf("-1\n");
  else if (n == m)
    printf("0 1\n");
  else if (n == m - 1) {
    int k = 0;
    for (; k < m; k++)
      if (a[k] != k) break;
    printf("%I64d 1\n", (k + 1) % m);
  } else if (n == 1)
    printf("%I64d 0\n", a[0]);
  else {
    long long invn = power(n, m - 2, m);
    S1 = invn * S1 % m;
    S2 = invn * S2 % m;
    long long d2 = (S2 - (S1 * S1 % m) + m) % m;
    d2 = 12 * d2 % m;
    long long invnm = power((n + m - 1) % m, m - 2, m);
    long long invnp = power((n + 1) % m, m - 2, m);
    d2 = invnm * d2 % m;
    d2 = invnp * d2 % m;
    if (legendre(d2, m) != 1)
      printf("-1\n");
    else {
      d = root(d2, m);
      x = (n - 1) * power(2, m - 2, m) % m;
      x = x * d % m;
      x = (S1 - x + m) % m;
      for (int k = 0; k < n; k++) test.push_back((x + k * d) % m);
      std::sort(test.begin(), test.end());
      bool compare = true;
      for (int k = 0; k < n; k++)
        if (test[k] != a[k]) compare = false;
      if (compare)
        printf("%I64d %I64d\n", x, d);
      else
        printf("-1\n");
    }
  }
  return 0;
}