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 *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. 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* + 2*d*, ..., *x* + (*n* - 1)·*d*, each taken modulo *m*.
The first line contains two integers *m* and *n* (2 ≤ *m* ≤ 10<sup class="upper-index">9</sup> + 7, 1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, *m* is prime) — Timofey's favorite prime module and the length of the sequence.

The second line contains *n* distinct integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> &lt; *m*) — the elements of the sequence.
none
17 5
0 2 4 13 15
13 2
17 5
0 2 4 13 14
-1
5 3
1 2 3
3 4
17 8
7 9 11 13 15 1 3 5
1 2
13 2
0 11
0 11
3 1
0
0 1
2 1
1
1 1
241 120
235 136 237 28 90 60 27 122 239 59 72 46 180 233 182 21 206 153 97 112 94 219 52 109 31 17 8 152 3 118 191 222 214 119 217 39 33 40 1 164 38 173 42 82 130 229 226 73 44 155 85 41 2 132 95 163 192 62 14 210 137 197 135 142 53 154 148 162 140 35 24 106 56 170 93 201 211 147 124 20 177 76 186 228 102 74 129 156 87 51 67 167 178 146 225 111 125 144 45 151 161 22 174 30 188 98 213 199 207 107 209 200 57 65 123 157 6 204 96 66
-1
241 120
114 147 193 143 206 74 60 15 75 197 192 93 115 166 116 88 14 46 156 229 7 5 233 188 111 179 102 73 187 196 57 211 137 134 201 92 29 224 160 2 110 119 184 202 20 174 124 225 97 105 1 216 155 161 19 125 101 205 78 38 178 123 87 16 142 47 28 215 219 23 70 238 120 210 69 10 55 128 25 6 42 169 79 65 56 175 170 107 214 61 43 228 24 237 96 133 34 83 152 220 234 66 52 51 84 183 146 173 33 164 151 11 207 157 165 129 64 138 37 106
173 191
17 17
15 1 6 3 7 8 10 13 12 16 11 9 14 2 0 4 5
1 1
7 3
3 4 1
-1
7 3
4 0 3
4 3
17 2
5 13
5 8
17 2
8 3
3 5
17 5
15 6 9 8 3
-1
17 5
2 5 14 8 11
2 3
17 8
1 10 6 8 2 16 9 15
-1
17 8
6 0 8 3 14 11 9 12
8 3
23 1
4
4 1
23 1
20
20 1
23 11
11 7 15 20 18 5 13 0 8 3 19
-1
23 11
11 4 0 3 2 14 22 12 13 15 1
22 12
239 100
35 96 173 36 220 188 102 227 226 237 16 97 79 211 156 49 146 222 57 209 121 201 166 123 61 29 67 89 184 72 14 47 193 127 165 76 171 30 120 68 108 228 130 151 221 139 214 18 210 169 87 100 13 52 196 148 122 86 131 208 65 194 43 178 9 118 0 24 183 45 134 55 71 212 111 106 170 80 179 233 180 238 235 75 153 105 182 70 197 143 31 207 145 83 20 113 101 190 6 64
-1
239 100
95 225 152 10 96 20 192 51 150 138 105 206 33 41 29 127 53 75 118 9 21 43 119 52 174 139 86 161 207 19 203 215 228 30 66 64 32 44 217 54 131 0 74 117 22 129 109 171 172 141 181 237 107 151 193 140 142 85 55 182 160 42 185 106 11 97 65 163 195 63 128 226 194 184 173 216 84 130 162 98 76 73 120 196 116 40 62 236 218 8 183 238 149 204 205 108 214 227 31 87
66 76
239 100
178 74 144 43 201 189 40 175 51 31 202 114 12 17 86 78 53 196 235 158 95 224 143 198 170 117 79 81 23 197 73 165 133 166 21 50 148 34 121 223 184 45 54 228 9 238 187 19 218 169 104 62 106 46 209 182 221 61 59 48 160 27 212 123 5 107 82 102 208 151 7 180 35 191 11 70 168 18 145 89 193 87 91 215 42 139 0 29 140 69 194 41 153 231 154 111 157 122 119 127
-1
239 100
9 107 11 203 36 34 35 91 20 3 42 19 225 169 99 41 43 28 113 83 193 219 153 129 155 90 123 17 209 97 235 51 73 27 234 138 49 98 81 106 58 186 139 187 226 25 224 18 65 210 131 121 67 82 137 89 60 145 232 227 179 44 33 1 194 59 195 177 2 74 233 170 50 202 10 201 162 52 105 57 26 161 218 146 171 163 66 115 217 154 122 178 130 75 211 4 12 185 147 114
224 8
7 4
5 2 1 4
2 3
7 4
5 2 1 6
6 3
17 16
11 14 7 15 13 6 3 0 4 10 12 1 16 5 8 9
3 1
17 16
10 0 7 5 13 3 16 14 1 6 8 15 2 9 12 11
5 1
from functools import reduce

def gcd_extended(bigger, less):
    if less == 0:
        return(bigger, 1, 0)
    mod = bigger % less
    div = bigger // less
    gcd, c_less, c_mod = gcd_extended(less, mod)
    #gcd == c_less * less + c_mod * mod
    #mod == bigger - div * less
    #gcd = (c_less - c_mod * div) * less
    #       + c_mod * bigger
    c_bigger = c_mod
    c_less = c_less - c_mod * div
    return(gcd, c_bigger, c_less)


def mlp_inverse(x, p):
    one, c_p, c_x = gcd_extended(p, x) #one == c_x * x + c_p * p
    return (c_x + p) % p


def tests(x, d, p, row):
    _row = set(row)
    n = len(row)
    if d == 0:
        return False
    for i in range(n):
        elem = x + i * d
        elem = (elem % p + p) % p
        if elem not in _row:
            return False
    return True


p, n = (int(x) for x in input().split())
row = [int(x) for x in input().split()]

#precounting constants
c1 = reduce(lambda x, y: (x + y) % p, row, 0)
c2 = reduce(lambda x, y: (x + y * y) % p, row, 0)
sum_i = reduce(lambda x, y: (x + y) % p, range(0, n), 0)
sum_i_sq = reduce(lambda x, y: (x + y * y) % p, range(0, n), 0)
inv_sum_i = mlp_inverse(sum_i, p)
inv_sum_i_sq = mlp_inverse(sum_i_sq, p)

#algorythm
for x in row:
    #
    d = (c1 - n * x) * inv_sum_i
    d = (d % p + p) % p
    equasion = n * x * x + 2 * d * sum_i + d * d * sum_i_sq
    equasion = (equasion % p + p) % p
    if (equasion == c2
        and tests(x, d, p, row)
       ):
        print(x, d)
        break
print(-1)
    


