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>
struct S {
  int i, p, q;
} ss[100000 + 100000];
int pp[20 + 1][100000 + 100000];
int compare_(const void *a, const void *b) {
  struct S *s = (struct S *)a;
  struct S *t = (struct S *)b;
  return s->p != t->p ? s->p - t->p : s->q - t->q;
}
int compare(const void *a, const void *b) {
  int ia = *(int *)a;
  int ib = *(int *)b;
  return ia - ib;
}
int dd[100000 + 100000];
int n_, b;
void init() {
  int a, u, i, i_, p;
  for (i = 0; i < n_; i++) ss[i].i = i;
  while (1 << b < n_) b++;
  for (i = 0; i < n_; i++) pp[0][i] = dd[i];
  for (a = 0; a < b; a++) {
    u = 1 << a;
    for (i = 0; i < n_; i++) {
      int i_ = ss[i].i;
      ss[i].p = pp[a][i_];
      ss[i].q = i_ + u >= n_ ? -1 : pp[a][i_ + u];
    }
    qsort(ss, n_, sizeof *ss, compare_);
    for (i = 0, p = 0; i < n_; i++) {
      i_ = ss[i].i;
      pp[a + 1][i_] =
          i == 0 || (ss[i - 1].p == ss[i].p && ss[i - 1].q == ss[i].q) ? p
                                                                       : ++p;
    }
  }
}
int lcp(int i, int j) {
  int a, l;
  if (i > j) return lcp(j, i);
  l = 0;
  for (a = b - 1; a >= 0 && j < n_; a--)
    if (pp[a][i] == pp[a][j]) {
      int u = 1 << a;
      i += u;
      j += u;
      l += u;
    }
  return l;
}
int good(int *aa, int n, int x) {
  int lower = -1, upper = n;
  while (upper - lower > 1) {
    int i = (lower + upper) / 2;
    if (aa[i] <= x)
      lower = i;
    else
      upper = i;
  }
  return lower >= 0 && aa[lower] == x;
}
int main() {
  static int aa[100000];
  int m, n, h, i, j;
  scanf("%d%d", &m, &n);
  if (n == m) {
    printf("0 1\n");
    return 0;
  }
  for (i = 0; i < n; i++) scanf("%d", &aa[i]);
  if (n == 1) {
    printf("%d 0", aa[0]);
    return 0;
  }
  qsort(aa, n, sizeof *aa, compare);
  n_ = n + n - 1;
  for (i = 0; i < n_; i++) {
    dd[i] = aa[(i + 1) % n] - aa[i % n];
    if (dd[i] < 0) dd[i] += m;
  }
  init();
  for (h = 1; h < n; h++) {
    int first, last;
    int x = aa[h] - aa[0];
    i = 0;
    j = h;
    first = last = -1;
    while (1) {
      int l = lcp(i, j);
      i += l + 1;
      j += l + 1;
      if (j >= h + n) {
        printf("%d %d\n", first, x);
        return 0;
      }
      while (!good(aa, n, (aa[i % n] + x) % m)) {
        if (last != -1) goto end;
        last = aa[i % n];
        i++;
      }
      while (!good(aa, n, (aa[j % n] - x + m) % m)) {
        if (first != -1) goto end;
        first = aa[j % n];
        j++;
      }
    }
  end:;
  }
  printf("-1\n");
  return 0;
}