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;
const int N = 200000 + 7;
const int M = 10007;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * (inf - 1);
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;
int lt[N], invlt[N];
int prime[N];
int last[N];
int numOfPrime = 0;
void thanos() {
  for (int i = 2; i < N; ++i) {
    if (last[i] == 0) {
      last[i] = i;
      prime[numOfPrime++] = i;
    }
    for (int j = 0; j < numOfPrime && prime[j] <= last[i] && prime[j] * i < N;
         ++j) {
      last[i * prime[j]] = prime[j];
    }
  }
}
int inverse(int x, int n) {
  int r = n, newr = x;
  int t = 0, newt = 1;
  while (newr > 0) {
    int q = r / newr;
    int tmp = newr;
    newr = r % newr;
    r = tmp;
    tmp = newt;
    newt = t - q * newt;
    t = tmp;
  }
  if (t < 0) t += n;
  return t;
}
void init() {
  lt[0] = invlt[0] = 1;
  for (int i = (1); i < (N); i++) {
    lt[i] = (long long)lt[i - 1] * i % inf;
    invlt[i] = inverse(lt[i], inf);
  }
}
int C(int n, int k) {
  return (long long)lt[n] * invlt[n - k] % inf * invlt[k] % inf;
}
long long pw(long long x, long long k) {
  if (!k)
    return 1;
  else if (k & 1)
    return pw(x, k - 1) * x % inf;
  long long tmp = pw(x, k / 2);
  return tmp * tmp % inf;
}
int m;
bool marked[N];
map<int, int> st;
int check(int d, vector<int>& a) {
  for (int i = 0; i < a.size(); ++i) marked[i] = false;
  int cnt = 0;
  int i = 0;
  while (!marked[i]) {
    marked[i] = true;
    ++cnt;
    int nxt = a[i] + d;
    if (nxt >= m) nxt -= m;
    if (!st.count(nxt)) break;
    i = st[nxt];
  }
  i = 0;
  do {
    int prv = a[i] - d;
    if (prv < 0) prv += m;
    if (!st.count(prv)) break;
    i = st[prv];
    if (marked[i])
      break;
    else
      ++cnt;
  } while (true);
  if (cnt != a.size())
    return -1;
  else
    return a[i];
}
pair<int, int> getAns(vector<int> a) {
  if (a.size() == 1) {
    return make_pair(a[0], 1);
  }
  if (a.size() == 2) {
    int d = a[1] - a[0];
    return make_pair(a[0], d);
  }
  st.clear();
  for (int i = (0); i < (a.size()); i++) st[a[i]] = i;
  int mlx = a[1] - a[0];
  int cnt = 0;
  for (int i = 0; i < a.size(); ++i) {
    int prv = a[i] - mlx;
    if (prv < 0) prv += m;
    if (st.count(prv)) ++cnt;
  }
  cnt = a.size() - cnt;
  for (int t = cnt - 1; t <= cnt + 1; ++t) {
    if (t > 0 && t < a.size()) {
      int d = 1ll * mlx * inverse(t, m) % m;
      int res = check(d, a);
      if (res != -1) {
        return make_pair(res, d);
      }
    }
  }
  return make_pair(-1, 1);
}
int a[N];
int n;
void solve() {
  init();
  cin >> m >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  if (n <= 2) {
    int d = 0;
    if (n == 2) d = a[1] - a[0];
    cout << a[0] << ' ' << d << '\n';
    return;
  }
  if (m == n) {
    cout << 0 << ' ' << 1 << '\n';
    return;
  }
  pair<int, int> res;
  if (2 * n < m) {
    vector<int> tmp;
    for (int i = 0; i < n; ++i) tmp.push_back(a[i]);
    res = getAns(tmp);
  } else {
    a[n] = m;
    vector<int> tmp;
    for (int j = 0; j < a[0]; ++j) tmp.push_back(j);
    for (int i = 0; i < n; ++i) {
      for (int j = a[i] + 1; j < a[i + 1]; ++j) {
        tmp.push_back(j);
      }
    }
    res = getAns(tmp);
    if (res.first != -1)
      res.first = (1ll * (m - n) * res.second % m + res.first) % m;
  }
  if (res.first == -1)
    puts("-1");
  else {
    cout << res.first << ' ' << res.second << '\n';
  }
}
void test() {
  freopen("in.txt", "w", stdout);
  for (int i = 0; i < 50000; ++i) {
    printf("%c", ((rand() % 26) + 'a'));
  }
  cout << '\n' << 100000 << '\n';
  for (int i = (0); i < (100000); i++) {
    for (int t = (0); t < ((rand() % 4) + 1); t++)
      printf("%c", ((rand() % 26) + 'a'));
    printf(" ");
    for (int t = (0); t < ((rand() % 4) + 1); t++)
      printf("%c", ((rand() % 26) + 'a'));
    printf("\n");
  }
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}