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;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <class T>
using v2d = vector<vector<T> >;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e5 + 10;
int n;
long long m, a[maxN], b[maxN], c[maxN], x, d;
bool fr[maxN];
long long power(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) {
      r = r * a % m;
    }
    b /= 2;
    a = a * a % m;
  }
  return r;
}
int Try(int index) {
  long long sum = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    b[i] = (a[i] - a[index] + m) % m;
    sum = (sum + b[i]) % m;
    fr[i] = 0;
  }
  multimap<long long, int> mp;
  for (int i = 1; i <= (int)(n); ++i) {
    if (i == index) {
      fr[i] = 1;
      continue;
    }
    auto it = mp.find(m - b[i]);
    if (it == mp.end()) {
      mp.emplace(b[i], i);
    } else {
      fr[i] = fr[it->second] = 1;
      mp.erase(it);
    }
  }
  int f = count(fr + 1, fr + n + 1, 1);
  if (f == n) {
    return 0;
  }
  long long h = 0;
  for (int i = 1, j = (f - 1) / 2 + 1; i <= n - f; ++i) {
    h += j;
    ++j;
  }
  h %= m;
  long long dd = sum * power(h, m - 2) % m;
  for (int i = 1, j = -(f - 1) / 2; i <= n; ++i, ++j) {
    c[i] = (j * dd % m + m) % m;
  }
  long long xx = (c[1] + a[index]) % m;
  sort(b + 1, b + n + 1);
  sort(c + 1, c + n + 1);
  for (int i = 1; i <= (int)(n); ++i) {
    if (b[i] != c[i]) {
      return -1;
    }
  }
  d = dd;
  x = xx;
  return 1;
}
void solve() {
  cin >> m >> n;
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> a[i];
  }
  map<long long, int> mp;
  for (int i = 1; i <= (int)(n); ++i) {
    ++mp[a[i]];
  }
  if ((int)mp.size() == 1) {
    cout << a[1] << ' ' << 0;
    return;
  }
  if (m > n && (int)mp.size() < n) {
    cout << -1;
    return;
  }
  if (m <= n) {
    if ((int)mp.size() < m) {
      cout << -1;
      return;
    }
    vector<int> e;
    for (auto &p : mp) {
      e.emplace_back(p.second);
    }
    sort((e).begin(), (e).end());
    e.resize(unique((e).begin(), (e).end()) - e.begin());
    if ((int)e.size() >= 3) {
      cout << -1;
      return;
    }
    n = 0;
    if ((int)e.size() == 1) {
      cout << a[1] << ' ' << 1;
      return;
    } else {
      for (auto &p : mp) {
        if (p.second > e[0]) {
          a[++n] = p.first;
        }
      }
    }
  }
  int ok = 0;
  if (n * 2 > m) {
    set<int> st;
    for (int i = 1; i <= (int)(n); ++i) {
      st.emplace(a[i]);
    }
    n = 0;
    for (int i = 0; i < (int)(m); ++i) {
      if (!st.count(i)) {
        a[++n] = i;
      }
    }
    if (n == 1) {
      x = a[1], d = 1, ok = 1;
    } else {
      int idx = 0;
      while (ok == 0) {
        ok = Try(++idx);
      }
    }
    x = (x + n * d) % m;
  } else {
    int idx = 0;
    while (ok == 0) {
      ok = Try(++idx);
    }
  }
  if (ok == 1) {
    cout << x << ' ' << d;
  } else {
    cout << -1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}