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 = 200005, M = 100005;
int mod;
template <class T>
inline void gmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void gmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline void ch(int &x, int y) { x = (x + y) % mod; }
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), rev = 0;
  while (ch > '9' || ch < '0') rev = (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x = rev ? -x : x;
}
template <class T>
inline void print(T x) {
  if (!x) {
    puts("0");
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int a[20], m = 0;
  while (x) a[m++] = x % 10, x /= 10;
  while (m--) putchar(a[m] + '0');
  puts("");
}
inline int exp(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
int n, s, d, a[N], d1[N], d2[N];
bool vis[N], rev;
bool find(int x) {
  x = (x % mod + mod) % mod;
  if ((*lower_bound(a + 1, a + n + 1, x)) == x) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  read(mod);
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  if (n == mod) {
    puts("0 1");
    return 0;
  }
  if (n * 2 > mod) {
    for (int i = 1; i <= n; i++) vis[a[i]] = 1;
    n = 0;
    rev = 1;
    for (int i = 0; i < mod; i++)
      if (!vis[i]) a[++n] = i;
  } else
    sort(a + 1, a + n + 1);
  a[n + 1] = -1;
  if (n == 1) {
    printf("%d 1\n", a[1] + rev);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    d1[i] = (a[i] - a[1] + mod) % mod, d2[i] = (a[i] - a[2] + mod) % mod;
  sort(d1 + 1, d1 + n + 1);
  d1[n + 1] = -1;
  int k = n, L = 0, R = 0;
  for (int i = 1; i <= n; i++) {
    int t = *lower_bound(d1 + 1, d1 + n + 1, d2[i]);
    if (t == d2[i]) k--;
  }
  if (!k) {
    puts("-1");
    return 0;
  }
  d = (long long)(a[1] - a[2] + mod) * exp(k, mod - 2) % mod;
  while (find(a[1] - (long long)(L + 1) * d % mod)) L++;
  while (find(a[1] + (long long)(R + 1) * d % mod)) R++;
  if (L + R + 1 < n) {
    puts("-1");
    return 0;
  }
  s = (a[1] - (long long)L * d % mod + mod) % mod;
  if (rev) s = (s + (long long)n * d) % mod;
  printf("%d %d\n", s, d);
  return 0;
}