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 INF = 1791791791;
const long long INFLL = 1791791791791791791ll;
long long pow(long long x, int n, long long m) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * pow(x, n ^ 1, m)) % m;
  else {
    long long t = pow(x, n >> 1, m);
    return (t * t) % m;
  }
}
long long divide(long long a, long long b, long long m) {
  return (a * pow(b, m - 2, m)) % m;
}
int n;
long long m;
vector<int> a;
bool is_good_difference(int d, int& first) {
  int y = a[0];
  int cnt = 0;
  auto it = lower_bound((a).begin(), (a).end(), y);
  while (it != a.end() && *it == y) {
    y += d;
    if (y >= m) y -= m;
    cnt++;
    it = lower_bound((a).begin(), (a).end(), y);
  }
  y = a[0];
  it = lower_bound((a).begin(), (a).end(), y);
  while (it != a.end() && *it == y) {
    first = y;
    y -= d;
    if (y < 0) y += m;
    cnt++;
    it = lower_bound((a).begin(), (a).end(), y);
  }
  return cnt == n + 1;
}
int count_differences(int d) {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int add = -d; add <= d; add += 2 * d) {
      int y = a[i] + add;
      if (y >= m) y -= m;
      if (y < 0) y += m;
      if (a[i] > y) continue;
      auto it = lower_bound((a).begin(), (a).end(), y);
      if (it != a.end() && *it == y) cnt++;
    }
  }
  return cnt;
}
pair<int, int> solve() {
  if (n == 0) return make_pair(1, 1);
  if (n == 1) return make_pair(a[0], 1);
  sort((a).begin(), (a).end());
  int first;
  int difference = a[1] - a[0];
  int k = n - count_differences(difference);
  int d = divide(difference, k, m);
  if (is_good_difference(d, first)) {
    return make_pair(first, d);
  } else {
    return make_pair(-1, -1);
  }
}
int main() {
  int cn;
  cin >> m >> n;
  cn = n;
  vector<int> c;
  c.resize(n);
  for (int i = 0; i < ((int)(n)); ++i) cin >> c[i];
  if (n == 1) {
    cout << c[0] << " 1" << endl;
    return 0;
  }
  pair<int, int> answer(-1, -1);
  if (2 * n >= m) {
    sort((c).begin(), (c).end());
    vector<int> b;
    for (int i = 0; i < m; i++) {
      auto it = lower_bound(c.begin(), c.end(), i);
      if (it == c.end() || *it != i) b.push_back(i);
    }
    n = m - n;
    a = b;
    pair<int, int> now = solve();
    if (now.first > -1) {
      answer.second = now.second;
      answer.first = (now.first + 1ll * n * now.second) % m;
    }
  } else {
    a = c;
    answer = solve();
  }
  if (answer.first == -1)
    cout << -1 << endl;
  else
    cout << answer.first << " " << answer.second << endl;
  return 0;
}