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>
using namespace std;
int GLL(long long& x) { return scanf("%lld", &x); }
int GI(int& x) { return scanf("%d", &x); }
int m, n;
long long add(long long x, long long y) {
  x += y;
  if (x >= m) x -= m;
  return x;
}
long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += m;
  return x;
}
long long mul(long long x, long long y) { return (x * y) % m; }
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= m;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
  }
  return res;
}
bool euler_criterion(long long a, long long p) {
  return powmod(a, (p - 1) / 2) == 1;
}
long long tonelli_shanks(long long a, long long p) {
  long long q = p - 1;
  long long s = 0;
  while (q % 2 == 0) {
    s++;
    q /= 2;
  }
  long long z = rand() % p;
  while (euler_criterion(z, p)) {
    z = rand() % p;
  }
  long long c = powmod(z, q);
  long long r = powmod(a, (q + 1) / 2);
  long long t = powmod(a, q);
  long long m = s;
  while (t != 1) {
    long long lo = 1, hi = m - 1;
    long long i = -1;
    while (lo <= hi) {
      long long mid = (lo + hi) / 2;
      if (powmod(t, 1LL << mid) == 1) {
        i = mid;
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    long long b = powmod(c, 1LL << (m - i - 1));
    r = mul(b, r);
    t = mul(t, mul(b, b));
    c = mul(b, b);
    m = i;
  }
  return r;
}
const int MAXN = 100005;
long long a[MAXN], d[MAXN], sqrd[MAXN], sumd[MAXN], sumsqrd[MAXN];
long long sumsqr[MAXN];
unordered_set<long long> sa, stest;
int main() {
  GI(m);
  GI(n);
  for (int i = 1; i <= (int)(n); i++) {
    GLL(a[i]);
    sa.insert(a[i]);
  }
  if (n == 0) {
    printf("%lld 0\n", a[0]);
    return 0;
  }
  memset(d, 0, sizeof d);
  memset(sqrd, 0, sizeof sqrd);
  memset(sumd, 0, sizeof sumd);
  memset(sumsqrd, 0, sizeof sumsqrd);
  sort(a + 1, a + n + 1);
  long long inv2 = powmod(2, m - 2);
  for (int i = 2; i <= n; i++) {
    d[i] = add(d[i - 1], mul(a[i] - a[i - 1], i - 1));
    sqrd[i] = add(add(sqrd[i - 1], mul(2, mul(a[i] - a[i - 1], d[i - 1]))),
                  mul(mul(a[i] - a[i - 1], a[i] - a[i - 1]), i - 1));
    sumd[i] = add(sumd[i - 1], d[i]);
    sumsqrd[i] = add(sumsqrd[i - 1], sqrd[i]);
  }
  memset(sumsqr, 0, sizeof sumsqr);
  for (int i = 1; i < MAXN; i++) sumsqr[i] = add(sumsqr[i - 1], mul(i, i));
  long long c = 0;
  for (int i = 1; i <= (int)(n - 1); i++) c = add(c, sumsqr[i]);
  long long test2 = mul(sumsqrd[n], powmod(c, m - 2));
  if (test2 == 0 || euler_criterion(test2, m)) {
    long long test = test2 == 0 ? 1 : tonelli_shanks(test2, m);
    int fwd = 0;
    long long curr = add(a[1], test);
    while (curr != a[1] && sa.find(curr) != sa.end()) {
      fwd++;
      curr = add(curr, test);
    }
    int bwd = 0;
    curr = sub(a[1], test);
    while (curr != a[1] && sa.find(curr) != sa.end()) {
      bwd++;
      curr = sub(curr, test);
    }
    if (fwd + bwd + 1 >= n) {
      curr = add(curr, test);
      printf("%lld %lld\n", curr, test);
    } else {
      printf("-1\n");
    }
  } else {
    printf("-1\n");
    return 0;
  }
  return 0;
}