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;
bool ok = true;
long long n, m, real_n;
long long a[100001];
bool in_a[200002];
int not_a[100001];
int checks = 0;
unordered_set<int> dict;
unordered_set<int> tried;
bool reversed = false;
bool exists(long long x) {
  unordered_set<int>::const_iterator got = dict.find(x);
  return (got != dict.end());
}
long long mod(long long a, long long m) {
  long long out = a % m;
  if (out < 0) {
    return out + m;
  }
  return out;
}
pair<int, int> check(long long x, long long y) {
  checks++;
  long long ct = 0;
  long long tmp = max(x, y);
  x = min(x, y);
  y = tmp;
  long long d = y - x;
  long long cur = 0;
  while (exists(mod(y + d * cur, m))) {
    cur++;
    ct++;
  }
  cur = 0;
  while (exists(mod(x + d * cur, m))) {
    cur--;
    ct++;
  }
  cur++;
  if (ct == real_n) {
    return pair<int, int>(mod(x + d * cur, m), d);
  }
  return pair<int, int>(-1, -1);
}
int main() {
  srand(18);
  cin >> m >> n;
  real_n = n;
  reversed = (n > m / 2);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (!reversed) dict.insert(a[i]);
  }
  if (reversed) {
    real_n = m - n;
    for (int i = 0; i < n; i++) {
      in_a[a[i]] = true;
    }
    int tmp = 0;
    for (int i = 0; i < m; i++) {
      if (!in_a[i]) {
        not_a[tmp] = i;
        tmp++;
        dict.insert(i);
      }
    }
  }
  if (n == 1) {
    cout << a[0] << " 1";
    return 0;
  }
  if (n == m - 1) {
    cout << (not_a[0] + 1) % m << " 1";
    return 0;
  }
  if (n == m) {
    cout << "1 1";
    return 0;
  }
  long long mx_iters = 1000000;
  long long r1 = 0;
  long long r2 = 0;
  for (long long z = 0; z < mx_iters; z++) {
    if (n > 2000 && checks > 1000) {
      cout << "too many checks not gonna work";
      return 0;
    }
    r2++;
    r2 %= real_n;
    if (r1 == r2) continue;
    int x = a[r1];
    int y = a[r2];
    if (reversed) {
      x = not_a[r1];
      y = not_a[r2];
    }
    long long d = -1;
    d = abs(x - y);
    if (tried.find(d) != tried.end()) {
      continue;
    }
    tried.insert(d);
    bool prune = false;
    for (int zz = 0; zz < 30; zz++) {
      long long k = rand() % (real_n / 2);
      long long k2 = rand() % (real_n / 2);
      if (!exists(mod(x + d * k, m)) && !exists(mod(x - d * k2, m))) {
        prune = true;
        break;
      }
    }
    if (prune) continue;
    pair<int, int> res = check(x, y);
    if (res.first != -1) {
      if (!reversed) {
        cout << res.first << " " << res.second;
      } else {
        cout << (res.first + (m - n) * d) % m << " " << res.second;
      }
      return 0;
    }
  }
  cout << "-1";
}