DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number x_{i}, DZY will put it into the bucket numbered h(x_{i}), where h(x) is the hash function. In this problem we will assume, that h(x) = x mod p. Operation a mod b denotes taking a remainder after division a by b.

However, each bucket can contain no more than one element. If DZY wants to insert an number into a bucket which is already filled, we say a "conflict" happens. Suppose the first conflict happens right after the i-th insertion, you should output i. If no conflict happens, just output -1.


-----Input-----

The first line contains two integers, p and n (2 ≤ p, n ≤ 300). Then n lines follow. The i-th of them contains an integer x_{i} (0 ≤ x_{i} ≤ 10^9).


-----Output-----

Output a single integer — the answer to the problem.


-----Examples-----
Input
10 5
0
21
53
41
53

Output
4

Input
5 5
0
1
2
3
4

Output
-1

Difficulty: EASY

Solutions:
(P, N) = list(map(int, input().split()))
MyDict = dict()
Conflict = 0
for i in range(N):
	Input = int(input())
	if Input % P in MyDict.keys():
		print(i + 1)
		exit()
	else:
		MyDict[Input % P] = 0
print(-1)


import sys
import math
(p, n) = [int(x) for x in sys.stdin.readline().split()]
k = [0] * p
for i in range(n):
	v = int(sys.stdin.readline())
	if k[v % p] > 0:
		print(i + 1)
		exit()
	else:
		k[v % p] += 1
print(-1)


(p, n) = map(int, input().split())
k = []
m = True
for i in range(n):
	j = int(input())
	if j % p not in k:
		k.append(j % p)
	else:
		print(i + 1)
		m = False
		break
if m:
	print(-1)


(p, n) = [int(i) for i in input().split()]
seen = set()
for i in range(1, n + 1):
	a = int(input()) % p
	if a in seen:
		print(i)
		break
	seen.add(a)
if len(seen) == n:
	print(-1)


(p, n) = map(int, input().split())
d = {}
for i in range(p):
	d.update({i: []})
(index, flag) = (-1, True)
for i in range(n):
	a = int(input())
	a = a % p
	d[a].append(1)
	if len(d[a]) > 1 and flag == True:
		flag = False
		index = i + 1
print(index)


(p, n) = map(int, input().split())
h = [False] * p
res = -1
for i in range(n):
	arr = int(input()) % p
	if h[arr]:
		res = i + 1
		break
	h[arr] = True
print(res)


(p, n) = map(int, input().split())
l = [int(input()) for _ in range(n)]
k = []
for i in range(n):
	if l[i] % p in k:
		print(i + 1)
		exit()
	k.append(l[i] % p)
print(-1)


import sys
import math
import bisect
import itertools
import random

def main():
	(m, n) = map(int, input().split())
	A = []
	for i in range(n):
		A.append(int(input()))
	s = set()
	ans = -1
	for i in range(n):
		if A[i] % m not in s:
			s.add(A[i] % m)
		else:
			ans = i
			break
	if ans == -1:
		print(-1)
	else:
		print(ans + 1)
main()


n = list(map(int, input().split(' ')))
arr = []
c = False
for i in range(n[1]):
	t = int(input())
	if t % n[0] in arr:
		print(i + 1)
		c = True
		break
	else:
		arr.append(t % n[0])
if c == False:
	print(-1)


h = []
a = -1
(P, N) = map(int, input().split())
for i in range(N):
	v = int(input()) % P
	if v in h and a == -1:
		a = i + 1
	h.append(v)
print(a)


(p, n) = [int(x) for x in input().split()]
s = set()
for i in range(n):
	x = int(input()) % p
	if x in s:
		print(i + 1)
		break
	s.add(x)
else:
	print(-1)


def main():
	d = {}
	(p, n) = input().split()
	p = int(p)
	n = int(n)
	for i in range(0, n):
		num = int(input())
		val = num % p
		res = d.get(val, -1)
		if res != -1:
			print(i + 1)
			return
		d[val] = num
	print(-1)
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(p, n) = get_int_list()
ans = [False] * p
count = 0
flag = True
for i in range(n):
	num = get_int()
	if ans[num % p] == False:
		ans[num % p] = True
	elif flag:
		count = i + 1
		flag = False
if count != 0:
	print(count)
else:
	print(-1)


import sys
(p, n) = map(int, input().split())
a = [0] * p
for i in range(n):
	x = int(input())
	if a[x % p] != 0:
		print(i + 1)
		sys.exit()
	else:
		a[x % p] = i + 1
print(-1)


def main():
	(p, n) = input().split()
	(p, n) = (int(p), int(n))
	c = True
	bucket = [False] * p
	for i in range(1, n + 1):
		x = int(input()) % p
		if bucket[x] is False:
			bucket[x] = True
		else:
			c = False
			break
	if c:
		print(-1)
	else:
		print(i)
main()


(p, _) = list(map(int, input().split()))
used = set()
for i in range(_):
	x = int(input())
	if x % p in used:
		print(i + 1)
		return
	else:
		used.add(x % p)
print(-1)


def inp():
	return map(int, input().split())
(p, n) = inp()
hash = dict({})
for i in range(n):
	x = int(input())
	if str(x % p) in hash:
		exit(print(i + 1))
	hash[str(x % p)] = x
print(-1)


(n, m) = map(int, input().split())
l = []
s = 0
for i in range(m):
	w = int(input())
	if w % n not in l:
		l.append(w % n)
	else:
		s = i + 1
		print(i + 1)
		break
if s == 0:
	print('-1')


(p, n) = map(int, input().split())
h = []
f = 1
for i in range(0, p):
	h.append(0)
for i in range(1, n + 1):
	x = int(input())
	if h[x % p]:
		f = 0
		break
	else:
		h[x % p] = 1
if f == 1:
	print(-1)
else:
	print(i)


alph = 'abcdefghijklmnopqrstuvwxyz'
(p, n) = map(int, input().split())
d = [-1] * p
for i in range(n):
	x = int(input())
	if d[x % p] == -1:
		d[x % p] = x
	else:
		print(i + 1)
		break
else:
	print(-1)


(p, n) = list(map(int, input().split()))
flag = 0
b = []
for i in range(n):
	x = int(input())
	hx = x % p
	if hx in b:
		print(i + 1)
		flag = 1
		break
	else:
		b.append(hx)
if flag == 0:
	print(-1)


Str = input()
ss = [int(s) for s in Str.split() if s.isdigit()]
p = ss[0]
n = ss[1]
ll = []
for i in range(n):
	x = int(input())
	r = x % p
	if r not in ll:
		ll.append(r)
	else:
		print(i + 1)
		break
else:
	print(-1)


(p, n) = map(int, input().split())
used = set()
for i in range(n):
	x = int(input())
	r = x % p
	if r in used:
		print(i + 1)
		exit()
	else:
		used.add(r)
print(-1)


(p, n) = map(int, input().split())
a = []
for i in range(n):
	x = int(input())
	if x % p in a:
		print(i + 1)
		exit()
	else:
		a.append(x % p)
print('-1')


(p, n) = map(int, input().split())
(ans, h) = (-1, [0] * p)
for i in range(n):
	a = int(input())
	if h[a % p] == 1:
		ans = i + 1
		break
	h[a % p] = 1
print(ans)


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	(p, n) = read_ints()
	vis = set()
	for i in range(n):
		x = read_int() % p
		if x in vis:
			print(i + 1)
			return
		vis.add(x)
	print(-1)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


(p, n) = map(int, input().split())
fl = -1
ar = []
for i in range(n):
	x = int(input())
	if x % p not in ar:
		ar.append(x % p)
	else:
		fl = i + 1
		break
print(fl)


(p, n) = map(int, input().split())
x = [i for i in range(p)]
check = 0
for i in range(n):
	z = int(input())
	t = z % p
	if x[t] != -1:
		x[t] = -1
	else:
		print(i + 1)
		check = 1
		break
if check == 0:
	print(-1)


def readln():
	return tuple(map(int, input().split()))
(p, n) = readln()
table = [0] * p
ans = -1
for i in range(n):
	(x,) = readln()
	if table[x % p]:
		ans = i + 1
		break
	table[x % p] = 1
print(ans)


(p, n) = tuple(map(int, input().split(' ')))
mods = []
result = -2
finished = False
for i in range(n):
	if finished:
		input()
	else:
		tmp = int(input()) % p
		if tmp in mods:
			result = i
			finished = True
		mods.append(tmp)
print(result + 1)


(p, n) = map(int, input().split())
a = []
for i in range(n):
	x = int(input())
	h = x % p
	if h in a:
		print(i + 1)
		break
	else:
		a.append(h)
if len(a) == n:
	print(-1)


import sys
l = []
(p, n) = map(int, input().split())
for i in range(1, n + 1):
	x = int(input()) % p
	if x not in l:
		l.append(x)
	else:
		print(i)
		sys.exit()
print(-1)


(p, n) = map(int, input().split())
b = [False for i in range(p)]
for i in range(n):
	x = int(input())
	if b[x % p] is True:
		break
	b[x % p] = True
else:
	print('-1')
	quit()
print(i + 1)


(p, n) = [int(x) for x in input().split()]
a = {}
res = -1
for i in range(n):
	t = int(input())
	if t % p in a and res == -1:
		res = i + 1
	else:
		a[t % p] = 1
print(res)


(p, n) = map(int, input().split())
busy = [False] * p
result = -1
for index in range(n):
	v = int(input()) % p
	if result != -1:
		continue
	if busy[v]:
		result = index + 1
	busy[v] = True
print(result)


(p, n) = map(int, input().split())
t = [False] * p
for i in range(n):
	k = int(input()) % p
	if t[k]:
		print(i + 1)
		exit(0)
	t[k] = True
print(-1)


(p, n) = map(int, input().split())
h = []
for _ in range(n):
	h.append(int(input()) % p)
k = []
for i in h:
	if i not in k:
		k.append(i)
	else:
		print(len(k) + 1)
		break
if k == h:
	print(-1)


(p, n) = map(int, input().split())
buckets = ['.'] * p
numbers = []
conflict = 0
for i in range(n):
	x = int(input())
	numbers.append(x)
for i in range(n):
	x = numbers[i] % p
	if buckets[x] != '.':
		print(i + 1)
		conflict += 1
		break
	else:
		buckets[x] = numbers[i]
if conflict == 0:
	print(-1)


string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
buckets = []
i = -1
for x in range(b):
	n = int(input())
	if not n % a in buckets:
		buckets.append(n % a)
	elif i == -1:
		i = x + 1
print(i)


(p, n) = map(int, input().split())
b = list()
for i in range(n):
	a = int(input())
	if a % p in b:
		print(i + 1)
		exit(0)
	else:
		b.append(a % p)
print(-1)


(m, d) = map(int, input().split())
w = set()
for i in range(d):
	a = int(input())
	if a % m in w:
		print(i + 1)
		exit()
	w.add(a % m)
print(-1)


def main():
	(p, n) = list(map(int, input().split()))
	table = set()
	for i in range(1, n + 1):
		x = int(input())
		if x % p in table:
			print(i)
			return
		else:
			table.add(x % p)
	print(-1)
	return

def __starting_point():
	main()
__starting_point()


(p, n) = [int(i) for i in input().split()]
res = -1
seen = set()
for i in range(1, n + 1):
	if res == -1:
		inp = int(input())
		temp = inp % p
		if temp in seen:
			res = i
			continue
		seen.add(temp)
	else:
		input()
print(res)


(p, n) = map(int, input().split())
used = [False] * p
for i in range(n):
	x = int(input())
	r = x % p
	if used[r]:
		print(i + 1)
		exit(0)
	else:
		used[r] = True
print(-1)


(p, n) = map(int, input().split())
hash_table = [-1] * p
flag = True
for i in range(n):
	x = int(input())
	hx = x % p
	if hash_table[hx] == -1:
		hash_table[hx] = x
	else:
		print(i + 1)
		flag = False
		break
if flag:
	print(-1)


(a, b) = map(int, input().split())
v = []
for _ in range(b):
	c = int(input())
	v.append(c % a)
if len(v) == len(set(v)):
	print(-1)
else:
	z = []
	for i in range(len(v)):
		if v[i] in z:
			print(i + 1)
			break
		else:
			z.append(v[i])


(p, n) = str(input()).split()
p = int(p)
n = int(n)
line = list()
flag = True
mark = 0
for i in range(n):
	if flag:
		c = int(input()) % p
		if c in line:
			mark = i + 1
			flag = False
		line.append(c)
if flag:
	print(-1)
else:
	print(mark)


(p, n) = map(int, input().split())
x = []
k = []
for i in range(n):
	z = int(input()) % p
	if z in x:
		k.append(i)
	x.append(z % p)
print(-1 if len(k) == 0 else k[0] + 1)


[p, n] = map(str, input().split(' '))
p = int(p)
n = int(n)
arr = []
ans = -1
for i in range(n):
	inp = int(input())
	b = inp % p in arr
	if b:
		if ans == -1:
			ans = i + 1
	arr.append(inp % p)
print(ans)


(a, n) = map(int, input().split())
l = []
for i in range(n):
	x = int(input())
	if x % a not in l:
		l.append(x % a)
	else:
		print(len(l) + 1)
		break
if len(l) == n:
	print(-1)


(p, n) = list(map(int, input().strip().split()))
l = []
for j in range(1, n + 1):
	m = int(input())
	t = m % p
	if t in l:
		print(j)
		break
	else:
		l += [t]
else:
	print('-1')


s = set()
(P, N) = [int(i) for i in input('').split()]
seen = False
for x in range(N):
	hashval = int(input(''))
	if (hashval + 1) % P not in s:
		s.add((hashval + 1) % P)
	else:
		seen = True
		break
if seen:
	print(x + 1)
else:
	print(-1)


def hash(p, array):
	hash = []
	for i in range(p):
		hash.append(-1)
	for i in range(len(array)):
		h = array[i] % p
		if hash[h] == -1:
			hash[h] = array[i]
		else:
			return i + 1
	return -1
str = input()
p = int(str.split(' ')[0])
n = int(str.split(' ')[1])
array = []
for i in range(n):
	array.append(int(input()))
print(hash(p, array))


a = list(input().split(' '))
(p, n) = (int(a[0]), int(a[1]))
a = list((0 for x in range(333)))
flag = False
for i in range(n):
	x = int(input())
	if a[x % p] != 0 and (not flag):
		print(i + 1)
		flag = True
	else:
		a[x % p] += 1
if not flag:
	print(-1)


s = input().split()
(p, n) = (int(s[0]), int(s[1]))
l = [False] * p
idx = -1
for i in range(n):
	x = int(input())
	if l[x % p]:
		idx = i + 1
		break
	else:
		l[x % p] = True
print(idx)


(p, n) = map(int, input().split())
s = set()
res = -1
for i in range(n):
	h = int(input()) % p
	if h in s:
		res = i + 1
		break
	s.add(h)
print(res)


(p, n) = map(int, input().split())
x = [0 for i in range(n)]
for i in range(n):
	x[i] = int(input())
was = [0 for i in range(p)]
k = -1
for i in range(n):
	if was[x[i] % p]:
		k = i + 1
		break
	else:
		was[x[i] % p] = 1
print(k)


(p, n) = map(int, input().split())
arr = []
brr = [0 for i in range(p)]
for i in range(n):
	y = int(input())
	arr.append(y)
count = 0
for i in range(n):
	x = arr[i] % p
	if brr[x] == 0:
		brr[x] = 1
		count += 1
	elif brr[x] != 0:
		break
if count < n:
	print(count + 1)
else:
	print(-1)


(p, n) = map(int, input().split())
result_dict = {}
a = [int(input()) for _ in range(n)]
index = 0
while index < len(a):
	if a[index] % p in result_dict:
		print(index + 1)
		break
	else:
		result_dict[a[index] % p] = a[index]
	index += 1
if index == len(a):
	print(-1)


(p, n) = [int(x) for x in input().split()]
arr = []
key = 0
for i in range(0, n):
	x = int(input())
	if x % p in arr:
		key = 1
		print(i + 1)
		break
	else:
		arr.append(x % p)
if key == 0:
	print(-1)


(a, b) = map(int, input().split())
c = []
for _ in range(b):
	f = int(input()) % a
	c += [f]
	if c.count(f) > 1:
		print(_ + 1)
		exit()
print(-1)


import sys
import string
from decimal import *
from itertools import *
from math import *

def solve():
	(p, n) = map(int, input().split())
	x = []
	for i in range(n):
		val = int(input())
		if val % p not in x:
			x.append(val % p)
		else:
			print(i + 1)
			return 0
	print(-1)
solve()


(p, n) = map(int, input().split())
vec = []
for i in range(n):
	vec.append(int(input()))
(h, j) = ({}, -1)
for i in range(n):
	if vec[i] % p in h:
		j = i
		break
	else:
		h[vec[i] % p] = vec[i]
if j != -1:
	print(j + 1)
else:
	print(-1)


from operator import itemgetter
(p, n) = map(int, input().split())
ai = [0] * p
ans = -1
for i in range(n):
	num = int(input())
	num = num % p
	if ai[num] == 1:
		ans = i + 1
		break
	ai[num] = 1
print(ans)


(p, n) = map(int, input().split())
ans = []
for i in range(n):
	x = int(input())
	ans.append(x % p)
z = []
for i in range(0, n - 1):
	for j in range(i + 1, n):
		if ans[i] == ans[j]:
			z.append(j + 1)
		else:
			continue
if len(z) == 0:
	print('-1')
else:
	print(min(z))


(p, n) = map(int, input().split())
a = []
b = []
for i in range(n):
	b.append(int(input()))
j = 1
for i in b:
	r = i % p
	if r in a:
		print(j)
		break
	else:
		a.append(r)
	j = j + 1
else:
	print(-1)


(p, n) = map(int, input().split())
a = []
i = 0
q = -1
while n > i:
	b = int(input()) % p
	if b in a and q == -1:
		q = i + 1
	a.append(b % p)
	i += 1
print(q)


(p, n) = map(int, input().split())
(l, f) = ([], 0)
for i in range(n):
	k = int(input())
	if k % p in l:
		print(i + 1)
		f = 1
		break
	else:
		l.append(k % p)
if f == 0:
	print(-1)


(mod, nb) = [int(x) for x in input().split()]
cnt = 0
ans = -1
done = []
for i in range(nb):
	curr = int(input()) % mod
	if curr in done:
		ans = i + 1
		break
	else:
		done.append(curr)
print(ans)


(p, n) = map(int, input().split())
lst = [-1] * p
res = -1
for i in range(n):
	x = int(input())
	if 0 <= x % p <= p - 1:
		if lst[x % p] == -1:
			lst[x % p] = x
		elif lst[x % p] != -1:
			res = i
			break
print(res if res < 0 else res + 1)


(p, n) = list(map(int, input().split(' ')))
l = []
for i in range(n):
	l.append(int(input()))
s = set()
for i in range(len(l)):
	m = l[i] % p
	if m in s:
		print(i + 1)
		break
	s.add(m)
else:
	print('-1')


(pp, n) = map(int, input().split())
a = []
p = []
for i in range(n):
	p.append(int(input()))
j = 1
for i in p:
	k = i % pp
	if k in a:
		print(j)
		break
	else:
		a.append(k)
	j = j + 1
else:
	print(-1)


(p, n) = map(int, input().split())
arr = [-1 for i in range(1000)]
for i in range(n):
	x = int(input())
	if arr[x % p] != -1:
		print(i + 1)
		exit()
	else:
		arr[x % p] = x
print(-1)


(p, n) = map(int, input().split())
hash_table = []
for i in range(0, n):
	x = int(input())
	if x % p in hash_table:
		print(i + 1)
		quit()
	else:
		hash_table.append(x % p)
print(-1)


(p, n) = map(int, input().split())
ns = [int(input()) for i in range(n)]
hs = [0] * p
res = -1
for i in range(n):
	if hs[ns[i] % p] > 0:
		res = i + 1
		break
	else:
		hs[ns[i] % p] += 1
print(res)


def h(x, p):
	return x % p

class CodeforcesTask447ASolution:

	def __init__(self):
		self.result = ''
		self.p_n = []
		self.inserts = []

	def read_input(self):
		self.p_n = [int(x) for x in input().split(' ')]
		self.inserts = [int(input()) for x in range(self.p_n[1])]

	def process_task(self):
		hashes = [False for x in range(self.p_n[0])]
		result = -1
		for (i, x) in enumerate(self.inserts):
			if hashes[h(x, self.p_n[0])]:
				if result < 0:
					result = i + 1
			else:
				hashes[h(x, self.p_n[0])] = True
		self.result = str(result)

	def get_result(self):
		return self.result
Solution = CodeforcesTask447ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(p, n) = map(int, input().split())
l = []
for i in range(n):
	x = int(input())
	s = x % p
	if s in l:
		print(i + 1)
		break
	else:
		l.append(s)
if len(l) == n:
	print(-1)


(m, n) = map(int, input().split())
b = set()
p = list()
for i in range(n):
	p.append(int(input()))
i = 1
for j in p:
	if j % m in b:
		print(i)
		break
	else:
		b.add(j % m)
		i += 1
else:
	print(-1)


(p, n) = map(int, input().split())
used = []
i = 1
found = False
while i <= n:
	num = int(input())
	if num % p in used:
		print(i)
		found = True
		break
	else:
		used.append(num % p)
	i += 1
if found == False:
	print('-1')


(p, n) = map(int, input().split())
k = [int(input()) for i in range(n)]

def h(x):
	return x % p
d = dict()
for i in range(len(k)):
	if h(k[i]) in d:
		print(i + 1)
		exit()
	else:
		d[h(k[i])] = 1
print(-1)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
(p, n) = value()
s = set()
for _ in range(n):
	k = int(input()) % p
	if k in s:
		print(_ + 1)
		exit()
	s.add(k)
print(-1)


def main():
	(p, n) = map(int, input().split())
	seen = [False] * p
	for i in range(1, n + 1):
		cur = int(input()) % p
		if seen[cur]:
			print(i)
			return
		else:
			seen[cur] = True
	print(-1)
main()


p = input().rstrip().split(' ')
P = int(p[0])
n = int(p[1])
l = [0] * 1000000
G = -78978
q = []
for i in range(0, n):
	o = int(input())
	q.append(o)
for i in range(0, len(q)):
	t = int(q[i]) % P
	if l[t] == 0:
		l[t] = 1
	else:
		G = i
		break
if G == -78978:
	print(-1)
else:
	print(G + 1)


def single_integer():
	return int(input())

def multi_integer():
	return map(int, input().split())

def string():
	return input()

def multi_string():
	return input().split()
(p, n) = multi_integer()
table = set()
for i in range(n):
	t = int(input())
	if t % p not in table:
		table.add(t % p)
	else:
		print(i + 1)
		break
else:
	print(-1)


s = input()
p = int(s.split()[0])
n = int(s.split()[1])
nn = []
bb = False
for i in range(n):
	a = int(input()) % p
	for b in nn:
		if b == a:
			print(i + 1)
			bb = True
			break
	else:
		nn.append(a)
	if bb:
		break
if not bb:
	print(-1)


s = input()
p = int(s.split()[0])
n = int(s.split()[1])
nn = set()
for i in range(n):
	a = int(input()) % p
	if a in nn:
		print(i + 1)
		raise SystemExit(0)
	else:
		nn.add(a)
print(-1)


import sys
(p, n) = [int(x) for x in input().split(' ')]
l = []
for i in range(n):
	l.append(int(input()))
s = set()
for i in range(len(l)):
	m = l[i] % p
	if m in s:
		print(i + 1)
		sys.exit()
	else:
		s.add(m)
print('-1')


(p, n) = [int(i) for i in input().split()]
mark = [0] * p
for i in range(n):
	num = int(input()) % p
	if mark[num] == 1:
		print(i + 1)
		break
	mark[num] = 1
else:
	print(-1)


(p, n) = map(int, input().split())
s = []
index = -1
for i in range(n):
	x = int(input())
	yy = x % p
	if yy in s:
		if index == -1:
			index = i + 1
	else:
		s.append(yy)
print(index)


(p, n) = map(int, input().split())
t = []
counter = 0
for i in range(n):
	x = int(input())
	if x % p in t:
		print(i + 1)
		exit()
	else:
		t.append(x % p)
print(-1)


(p, n) = map(int, input().split())
p_list = [[] for _ in range(p)]
for i in range(n):
	m = int(input())
	ind = m % p
	if p_list[ind] == []:
		p_list[ind] = 1
	else:
		print(i + 1)
		exit()
print(-1)


def solution():
	(p, n) = (int(x) for x in input().split())
	mas = [False] * p
	for i in range(n):
		x = int(input())
		if not mas[x % p]:
			mas[x % p] = True
		else:
			return i + 1
	return -1
print(solution())


(p, n) = tuple((int(i) for i in input().split()))
hash = set()

def solve():
	global p, n, hash
	for i in range(n):
		k = int(input()) % p
		if k in hash:
			print(i + 1)
			return
		hash.add(k)
	print(-1)
	return
solve()


(p, n) = [int(_) for _ in input().split()]
d = {}
ans = -1
f = True
for i in range(n):
	x = int(input())
	if f and x % p in d:
		ans = i + 1
		f = False
	else:
		d[x % p] = 1
print(ans)


(n, m) = map(int, input().split())
l = []
v = 1
for i in range(m):
	a = int(input())
	if a % n in l:
		print(v)
		exit()
		break
	else:
		l.append(a % n)
		v = v + 1
print(-1)


inp = input().split()
p = int(inp[0])
n = int(inp[1])
hash = [False] * p
ans = -1
for i in range(n):
	a = int(input()) % p
	if hash[a]:
		ans = i + 1
		break
	hash[a] = True
print(ans)


a = input().split()
p = int(a[0])
n = int(a[1])
h = []
flag = 1
for i in range(p):
	h.append(0)
for i in range(n):
	work = int(input())
	work = work % p
	if h[work] and flag:
		answer = i + 1
		flag = 0
	h[work] = 1
if flag:
	answer = -1
print(answer)


(p, n) = (int(x) for x in input().split())
table = {}
res = -1
for i in range(n):
	val = int(input())
	hash = val % p
	if hash in table.keys():
		res = i
		break
	else:
		table[hash] = val
print(res + 1 if res != -1 else res)


def main():
	r = lambda : tuple(map(int, input().split()))
	(p, n) = r()
	x = set()
	for i in range(n):
		d = r()[0] % p
		if d in x:
			print(i + 1)
			return
		else:
			x.add(d)
	print(-1)
main()


(n, m) = map(int, input().split())
x = []
t = [-1] * m
j = 0
c = False
for i in range(m):
	x += list(map(int, input().split()))
for k in range(m):
	t[j] = x[k] % n
	j += 1
for l in range(m):
	for y in range(0, l):
		if l != y:
			if t[l] == t[y]:
				c = True
				print(l + 1)
				exit()
if c == False:
	print(-1)


def main_function():
	(p, n) = [int(i) for i in input().split(' ')]
	hash_table = [0 for i in range(p)]
	korea = False
	japan = 0
	for i in range(1, n + 1):
		b = int(input())
		if hash_table[b % p] == 1:
			korea = True
			japan = i
			break
		else:
			hash_table[b % p] = 1
	if korea:
		return str(japan)
	return '-1'
print(main_function())


(x, y) = [int(z) for z in input().split()]
l = []
r = 0
m = y
while y != 0:
	p = int(input())
	p = p % x
	if p not in l:
		l.append(p)
	elif r == 0:
		r = y
	y -= 1
if r == 0:
	print(-1)
else:
	print(m - r + 1)


(p, n) = map(int, input().split())
number = -1
was = []
for i in range(n):
	c = int(input()) % p
	if c in was:
		number = i + 1
		break
	was.append(c)
print(number)


(p, n) = map(int, input().split())
l = [0] * p
d = 0
for i in range(n):
	a = int(input())
	c = a % p
	if l[c] == 1:
		if d == 0:
			d = i + 1
	else:
		l[c] = 1
if d == 0:
	print(-1)
else:
	print(d)


(p, n) = map(int, input().split())
d = {}
for i in range(n):
	x = int(input()) % p
	if x in d:
		print(i + 1)
		quit()
	d[x] = 1
print(-1)


(n, m) = map(int, input().split())
(k, kl) = ([], [])
for i in range(m):
	kl.append(int(input()))
for (i, j) in enumerate(kl):
	t = j % n
	if t not in k:
		k.append(t)
	else:
		print(i + 1)
		exit()
print(-1)


(p, n) = map(int, input().split())
a = [-1 for i in range(p)]
for i in range(n):
	b = int(input())
	if a[b % p] != -1:
		print(i + 1)
		return
	else:
		a[b % p] = b
print(-1)


(p, n) = list(map(int, input().split()))
T = [-1 for i in range(p)]
_col = -1
for i in range(n):
	a = int(input())
	if T[a % p] == -1:
		T[a % p] = a
	elif _col == -1:
		_col = i + 1
print(_col)


(n, k) = map(int, input().split())
d = 0
l = []
c = []
for i in range(k):
	x = int(input())
	l.append(x)
for i in range(k):
	j = l[i] % n
	if j not in c:
		c.append(j)
	else:
		d = i + 1
		break
if d == 0:
	print(-1)
else:
	print(d)


(p, n) = map(int, input().split())
d = {}
f = True
for i in range(p):
	d[i] = -1
for i in range(n):
	t = int(input())
	h = t % p
	if d[h] != -1:
		print(i + 1)
		f = False
		break
	else:
		d[h] = t
if f:
	print(-1)


__author__ = 'Сергей'
(p, n) = (int(x) for x in input().split())

def hash(x):
	return x % p
dict = {}
for i in range(n):
	key = hash(int(input()))
	if key in dict:
		print(i + 1)
		exit()
	else:
		dict[key] = True
print(-1)


(p, n) = [int(x) for x in input().split()]
s = set()
f = True
answer = -1
for i in range(n):
	x = int(input())
	if x % p not in s:
		s.add(x % p)
	elif f:
		answer = i + 1
		f = False
print(answer)


(p, n) = map(int, input().split())
x = [int(input()) for i in range(n)]
u = [False] * p
for i in range(min(p + 1, n)):
	if u[x[i] % p]:
		print(i + 1)
		break
	u[x[i] % p] = True
else:
	print(-1)


(p, n) = map(int, input().split())
l = []
t = []
test = 0
for i in range(n):
	x = int(input())
	t.append(x)
for i in range(n):
	x = t[i]
	x = x % p
	if x in l:
		test = 1
		break
	else:
		l.append(x)
if test:
	print(i + 1)
else:
	print(-1)


def solve(arr, p):
	d = {}
	for i in range(len(arr)):
		res = arr[i] % p
		if not d.get(res):
			d[res] = 1
		else:
			return i + 1
	return -1

def main():
	(p, n) = list(map(int, input().split(' ')))
	arr = []
	for _ in range(n):
		i = int(input())
		arr.append(i)
	print(solve(arr, p))
main()


f = lambda : map(int, input().split())
(p, n) = f()
h = []
for i in range(n):
	x = int(input())
	if not x % p in h:
		h.append(x % p)
	else:
		exit(print(i + 1))
print(-1)


(n, m) = map(int, input().split())
li = []
for i in range(m):
	a = int(input()) % n
	if not a in li:
		li.append(a)
	else:
		print(i + 1)
		exit(0)
else:
	print('-1')


def main():
	(p, n) = map(int, input().split())
	ha = [False] * p
	for (i, x) in enumerate((int(input()) % p for _ in range(n))):
		if ha[x]:
			return i + 1
		ha[x] = True
	return -1
print(main())


(p, n) = map(int, input().split(' '))
ans = 0
list = []
for i in range(n):
	x = int(input())
	x = x % p
	if x in list:
		ans = i
		break
	else:
		list.append(x)
if ans == 0:
	print(-1)
else:
	print(ans + 1)