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
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
template <class T>
inline T isqrt(T k) {
  T r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
template <class T>
inline T icbrt(T k) {
  T r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
int p = (int)1e9 + 7;
template <class T, class mul, class dvd>
struct FiniteField {
  T x;
  template <class G>
  T normalize(G x) {
    if (x >= 0 && x < p) return x;
    x %= p;
    if (x < 0)
      x += p;
    else if (x >= p)
      x -= p;
    return x;
  }
  FiniteField() : x(0) {}
  template <class G>
  FiniteField(const G& y) {
    x = normalize(y);
  }
  FiniteField(const FiniteField& rhs) : x(rhs.x) {}
  template <class G>
  FiniteField operator()(const G& y) {
    x = normalize(y);
    return *this;
  }
  template <class G>
  FiniteField operator=(const G& y) {
    x = normalize(y);
    return *this;
  }
  int operator==(const FiniteField& rhs) const { return x == rhs.x; }
  int operator!=(const FiniteField& rhs) const { return x != rhs.x; }
  int operator<(const FiniteField& rhs) const { return x < rhs.x; }
  FiniteField operator++(int) {
    FiniteField res = *this;
    if ((++x) >= p) x -= p;
    return res;
  }
  FiniteField operator++() {
    if ((++x) >= p) x -= p;
    return *this;
  }
  FiniteField operator--(int) {
    FiniteField res = *this;
    if ((--x) < 0) x += p;
    return res;
  }
  FiniteField operator--() {
    if ((--x) < 0) x += p;
    return *this;
  }
  template <class G>
  FiniteField operator+=(const G& y) {
    if ((x += normalize(y)) >= p) x -= p;
    return *this;
  }
  template <class G>
  FiniteField operator-=(const G& y) {
    if ((x -= normalize(y)) < 0) x += p;
    return *this;
  }
  FiniteField operator+=(const FiniteField& rhs) {
    if ((x += rhs.x) >= p) x -= p;
    return *this;
  }
  FiniteField operator-=(const FiniteField& rhs) {
    if ((x -= rhs.x) < 0) x += p;
    return *this;
  }
  FiniteField operator+(const FiniteField& rhs) const {
    FiniteField res;
    res.x = x + rhs.x;
    if (res.x >= p) res.x -= p;
    return res;
  }
  FiniteField operator-(const FiniteField& rhs) const {
    FiniteField res;
    res.x = x - rhs.x;
    if (res.x < 0) res.x += p;
    return res;
  }
  template <class G>
  FiniteField operator*=(const G& y) {
    x = mul()(x, normalize(y), p);
    return *this;
  }
  template <class G>
  FiniteField operator/=(const G& y) {
    x = dvd()(x, normalize(y), p);
    return *this;
  }
  template <class G>
  FiniteField operator*(const G& y) const {
    FiniteField res;
    res.x = mul()(x, res.normalize(y), p);
    return res;
  }
  template <class G>
  FiniteField operator/(const G& y) const {
    FiniteField res;
    res.x = dvd()(x, res.normalize(y), p);
    return res;
  }
  FiniteField operator*(const FiniteField& rhs) const {
    FiniteField res;
    res.x = mul()(x, rhs.x, p);
    return res;
  }
  FiniteField operator/(const FiniteField& rhs) const {
    FiniteField res;
    res.x = dvd()(x, rhs.x, p);
    return res;
  }
  template <class G>
  friend FiniteField operator*(const G& y, const FiniteField& rhs) {
    FiniteField res;
    res.x = res.normalize(y);
    return res * rhs;
  }
  template <class G>
  friend FiniteField operator/(const G& y, const FiniteField& rhs) {
    FiniteField res;
    res.x = res.normalize(y);
    return res / rhs;
  }
  template <class G>
  FiniteField operator^=(G k) {
    if (k == 0) {
      x = 1;
      return *this;
    }
    T t = x;
    k--;
    while (k > 0) {
      if (k & 1) x = mul()(x, t, p);
      t = mul()(t, t, p);
      k >>= 1;
    }
    return *this;
  }
  template <class G>
  FiniteField operator^(G k) const {
    if (k == 0) return 1;
    T r = x, t = x;
    k--;
    while (k > 0) {
      if (k & 1) r = mul()(r, t, p);
      t = mul()(t, t, p);
      k >>= 1;
    }
    return r;
  }
  friend istream& operator>>(istream& is, FiniteField& rhs) {
    is >> rhs.x;
    return is;
  }
  friend ostream& operator<<(ostream& os, const FiniteField& rhs) {
    os << rhs.x;
    return os;
  }
};
template <class T>
class mul {
 public:
  T operator()(const T& x, const T& y, const T& p) {
    return (long long)x * y % p;
  }
};
template <class T>
class dvd {
 public:
  T operator()(const T& x, const T& y, const T& p) {
    pair<T, T> r = euclid(y, p);
    return mul<T>()(x, (r.first % p + p) % p, p);
  }

 private:
  pair<T, T> euclid(T a, T b) {
    if (b == 0) return make_pair(1, 0);
    pair<T, T> r = euclid(b, a % b);
    return make_pair(r.second, r.first - a / b * r.second);
  }
};
const int maxn = 100000 + 5;
int m, n;
FiniteField<int, mul<int>, dvd<int> > a[maxn];
map<FiniteField<int, mul<int>, dvd<int> >, int> hs;
void solve() {
  cin >> m >> n;
  p = m;
  for (int i = (0); i < (n); i++) cin >> a[i];
  if (n == 1) {
    cout << a[0] << " " << 0 << "\n";
    return;
  }
  if (n == p) {
    cout << 0 << " " << 1 << "\n";
    return;
  }
  FiniteField<int, mul<int>, dvd<int> > sum = 0, sqsum = 0;
  for (int i = (0); i < (n); i++) sum += a[i], sqsum += a[i] * a[i], hs[a[i]];
  for (int i = (0); i < (n); i++) {
    FiniteField<int, mul<int>, dvd<int> > x = a[i];
    FiniteField<int, mul<int>, dvd<int> > d = (sum / n - x) * 2 / (n - 1);
    if (d == 0) continue;
    if (sqsum !=
        x * x * n + x * d * n * (n - 1) + d * d * (n - 1) * n * (2 * n - 1) / 6)
      continue;
    int ok = 1;
    for (int j = (0); j < (n); j++) {
      if (!hs.count(x + j * d)) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      cout << x << " " << d << "\n";
      return;
    }
  }
  cout << -1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
