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;
vector<int> arr, tmp;
vector<bool> ck;
int N, M;
bool find(int k) {
  int L = 0, R = (int)arr.size() - 1;
  while (L <= R) {
    int M = (L + R) / 2;
    if (arr[M] == k) {
      return true;
    } else if (arr[M] > k) {
      R = M - 1;
    } else {
      L = M + 1;
    }
  }
  return false;
}
int power(int x, int p) {
  if (p == 0) {
    return 1;
  }
  long long ret = power(x, p / 2);
  ret = (ret * ret) % M;
  if (p & 1) {
    ret = (ret * x) % M;
  }
  return (int)ret;
}
int main() {
  scanf("%d%d", &M, &N);
  for (int i = 1, t; i <= N; i++) {
    scanf("%d", &t);
    arr.push_back(t);
  }
  if (N > M) {
    cout << -1;
    return 0;
  }
  if (2 * N > M) {
    ck = vector<bool>(M, false);
    for (int i = 0; i < N; i++) {
      ck[arr[i]] = true;
    }
    for (int i = 0; i <= M - 1; i++) {
      if (ck[i] == false) {
        tmp.push_back(i);
      }
    }
    arr.clear();
    for (int i = 0; i < tmp.size(); i++) {
      arr.push_back(tmp[i]);
    }
    tmp.clear();
  }
  if (arr.size() == 0) {
    cout << arr[0] << " " << 1;
    return 0;
  }
  if (arr.size() == 1) {
    if (2 * N <= M)
      cout << arr[0] << " " << 1;
    else
      cout << (arr[0] + 1) % M << " " << 1;
    return 0;
  }
  sort(arr.begin(), arr.end());
  int x = arr[1] - arr[0];
  int cnt = 0;
  for (int i = 0; i < arr.size(); i++) {
    if (find((arr[i] + x) % M)) cnt++;
    if (find((arr[i] - x + M) % M)) cnt++;
  }
  int k = (int)arr.size() - cnt / 2;
  int d = ((long long)x * power(k, M - 2)) % M;
  int cur = arr[0], s = 0, e = 0;
  cnt = 0;
  while (find(cur)) {
    cnt++;
    s = cur;
    cur = (cur - d + M) % M;
  }
  cur = (arr[0] + d) % M;
  while (find(cur)) {
    cnt++;
    e = cur;
    cur = (cur + d) % M;
  }
  if (cnt != arr.size()) {
    cout << -1;
    return 0;
  }
  if (2 * N < M)
    cout << s << " " << d;
  else
    cout << (e + d) % M << " " << d;
  return 0;
}