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
Tags: Implementation

Starter code:

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)


(a, b) = map(int, input().split())
d = {}
k = 0
for i in range(b):
	p = int(input())
	if p % a in d:
		k = 1
		print(i + 1)
		break
	else:
		d[p % a] = p
if k == 0 and i == b - 1:
	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)


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


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) = map(int, input().split())
l = []
for i in range(n):
	x = int(input())
	if x % p not in l:
		l.append(x % p)
		flag = 0
	elif x % p in l:
		print(i + 1)
		flag = 1
		break
if flag == 0:
	print(-1)


(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)


from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit, maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits
prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x, y) % mod, l)

def read_list(t):
	return [t(x) for x in input().split()]

def read_line(t):
	return t(input())

def read_lines(t, N):
	return [t(input()) for _ in range(N)]
(p, n) = read_list(int)
bucket = [False] * p
for (i, num) in enumerate(read_lines(int, n)):
	if bucket[num % p]:
		print(i + 1)
		break
	else:
		bucket[num % p] = True
else:
	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)


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


(p, n) = [int(x) for x in input().split()]
dctr = {}
for i in range(n):
	x = int(input())
	h = x % p
	if h not in dctr:
		dctr[h] = True
	else:
		print(i + 1)
		break
else:
	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)


l = []
a = -1
(p, n) = map(int, input().split())
for i in range(n):
	temp = int(input())
	t = temp % p
	if t in l and a == -1:
		a = i + 1
	l.append(t)
print(a)


(m, n) = map(int, input().split())
h = []
for i in range(m):
	h.append(0)
for i in range(n):
	x = int(input())
	if h[x % m] == 1:
		print(i + 1)
		exit()
	else:
		h[x % m] = 1
print(-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')


import sys
import collections
input = sys.stdin.readline

def printnl(val):
	sys.stdout.write(str(val) + '\n')
(p, n) = map(int, input().split())
buckets = [0] * p
for i in range(n):
	x = int(input())
	buckets[x % p] += 1
	if buckets[x % p] == 2:
		print(i + 1)
		sys.exit(0)
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())
ok = -1
b = [0] * m
for i in range(n):
	a = int(input()) % m
	if b[a]:
		ok = i + 1
		break
	b[a] = 1
print(ok)


(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())
b = []
for i in range(n):
	m = int(input()) % p
	if m in b:
		print(i + 1)
		quit()
	else:
		b.append(m)
print(-1)


a = [0 for i in range(305)]
cur = -1
(p, n) = [int(i) for i in input().split()]
for i in range(n):
	b = int(input())
	a[b % p] += 1
	if a[b % p] == 2:
		cur = i + 1
		break
print(cur)


from sys import exit
(p, n) = map(int, input().split())
essi = [True] * p
for i in range(n):
	xi = int(input())
	yy = xi % p
	if essi[yy] == False:
		print(i + 1)
		exit()
	else:
		essi[yy] = False
print(-1)


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


(p, n) = map(int, input().split())
i = j = ans = 0
arr = []
while i < n:
	inp = int(input())
	x = inp % p
	if x in arr:
		print(i + 1)
		exit()
	arr.append(x)
	i += 1
print(-1)


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


import sys
(p, n) = map(int, input().split())
s = set()
for i in range(n):
	x = int(input()) % p
	if x in s:
		print(i + 1)
		sys.exit(0)
	s.add(x)
print(-1)


__author__ = 'Adela'

def main():
	(p, n) = (int(k) for k in input().split())
	full = [False] * p
	for i in range(n):
		xi = int(input())
		mod = xi % p
		if full[mod]:
			print(i + 1)
			return
		full[mod] = True
	print(-1)

def __starting_point():
	main()
__starting_point()


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
(p, n) = rints()
b = [False] * p
for i in range(n):
	xi = rint()
	if b[xi % p]:
		print(i + 1)
		exit(0)
	b[xi % p] = True
print(-1)


a = input().split()
l = []
for i in range(int(a[1])):
	b = int(input())
	l.append(b)
p = []
s = 0
for j in range(int(a[1])):
	if l[j] % int(a[0]) not in p:
		p.append(l[j] % int(a[0]))
		s = 1
	else:
		s = 2
		print(j + 1)
		break
if s == 1:
	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())
xlist = []
for i in range(n):
	xlist.append(int(input()))
remainderlist = []
for i in range(n):
	if xlist[i] % p not in remainderlist:
		remainderlist.append(xlist[i] % p)
	else:
		print(i + 1)
		quit()
print(-1)


import sys

def main():
	(p, n, *l) = map(int, sys.stdin.read().strip().split())
	s = set()
	for (i, j) in enumerate(l, 1):
		t = j % p
		if t in s:
			return i
		s.add(j % p)
	return -1
print(main())


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


import itertools

def main():
	(p, n) = [int(v) for v in input().split()]
	r = set()
	for i in range(n):
		v = int(input())
		if v % p in r:
			print(i + 1)
			return
		r.add(v % p)
	print(-1)
main()


(p, n) = map(int, input().split())
a = []
for i in range(p):
	a.append(i)
b = [0] * p
c = dict(zip(a, b))
for i in range(n):
	x = int(input())
	c[x % p] = c[x % p] + 1
	if c[x % p] > 1:
		print(i + 1)
		break
else:
	print('-1')


def solution(l1, p):
	l1 = [x % p for x in l1]
	t = []
	i = 0
	while i < len(l1):
		if l1[i] not in t:
			t.append(l1[i])
		else:
			return i + 1
		i += 1
	return -1

def answer():
	a = [int(x) for x in input().split()]
	l1 = []
	while a[1]:
		l1.append(int(input()))
		a[1] -= 1
	print(solution(l1, a[0]))
answer()


def main():
	[p, n] = [int(_) for _ in input().split()]
	conflict_i = -1
	hashed = {}
	for i in range(n):
		s = input()
		if conflict_i == -1:
			number = int(s) % p
			if number in hashed:
				conflict_i = i + 1
			else:
				hashed[number] = True
	print(conflict_i)
main()


def hash(array, p):
	table = {}
	for i in range(len(array)):
		hx = array[i] % p
		if hx in table:
			return i + 1
		else:
			table[hx] = array[i]
	return -1
n = list(map(int, input().split()))
i = 0
p = n[0]
array = []
while i < n[1]:
	x = input()
	array.append(int(x))
	i += 1
print(hash(array, p))


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


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


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


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


(p, n) = input().split()
n = int(n)
p = int(p)

def f(n, p):
	l = []
	for i in range(1, n + 1):
		a = int(input()) % p
		if a in l:
			return i
		l.append(a)
	return -1
print(f(n, p))


(p, n) = map(int, input().split())
arr = [0] * p
ok = -1
for _ in range(n):
	x = int(input())
	if arr[x % p]:
		ok = _ + 1
		break
	else:
		arr[x % p] = 1
print(ok)


(p, n) = map(int, input().split())
f = 0
l = list(range(p))
for i in range(n):
	x = int(input())
	if x % p in l:
		l.remove(x % p)
	else:
		print(i + 1)
		f = 1
		break
if f == 0:
	print(-1)


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


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


from collections import defaultdict

def func():
	(p, n) = [int(x) for x in input().split()]
	table = defaultdict(int)
	for index in range(0, n):
		x = int(input())
		if table[x % p] == 1:
			return index + 1
		table[x % p] = 1
	return -1
print(func())


(p, n) = map(int, input().split())
t = [-1] * p
r = -1
for i in range(n):
	x = int(input()) % p
	if r == -1 and t[x] != -1:
		r = i + 1
	t[x] = 1
print(r)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
(p, n) = map(int, input().split())
a = []
for x in range(n):
	b = int(input())
	if b % p in a:
		print(x + 1)
		exit(0)
	a.append(b % p)
print(-1)


inp = input().strip().split()
inp = [int(i) for i in inp]
p = inp[0]
n = inp[1]
hashDict = {}
conflict = False
insertion = 0
for i in range(n):
	num = int(input().strip())
	num = num % p
	if num in hashDict:
		if conflict:
			continue
		conflict = True
		insertion = i
	else:
		hashDict[num] = True
if conflict:
	print(insertion + 1)
else:
	print('-1')


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


AkshajK = input('').split()
p = int(AkshajK[0])
n = int(AkshajK[1])
c = 1
asdf = []
l_1 = []
for x in range(p):
	l_1.append(0)
while c <= n:
	s = int(input())
	if l_1[s % p] == 0:
		l_1[s % p] = 1
	else:
		asdf.append(c)
	c += 1
if asdf != []:
	print(asdf[0])
else:
	print(-1)


def solve():
	(p, n) = map(int, input().split())
	a = []
	for _ in range(n):
		a.append(int(input()))
	myset = set()
	for i in range(n):
		x = a[i]
		if x % p in myset:
			return i + 1
		else:
			myset.add(x % p)
	return -1
print(solve())


(p, n) = map(int, input().split())
mod = [0] * (p + 2)
for i in range(1, n + 1):
	j = int(input())
	if mod[j % p]:
		print(i)
		exit(0)
	mod[j % p] = 1
print(-1)


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


(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)


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


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)


(p, n) = map(int, input().split())
h = []
flag = 0
for i in range(n):
	x = int(input())
	y = x % p
	if y in h and flag == 0:
		print(i + 1)
		flag = 1
	else:
		h.append(y)
	if flag == 0 and i == n - 1:
		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)


from collections import Counter
(n, k) = map(int, input().split())
c = Counter()
ans = -1
for i in range(1, k + 1):
	x = int(input())
	c[x % n] += 1
	if ans == -1 and c[x % n] > 1:
		ans = i
print(ans)


import math
sa3 = []
sa2 = input().split(' ')
prime = int(sa2[0])
nums = int(sa2[1])
for x in range(nums):
	sa = int(input())
	sa3.append(sa)
sa4 = []
sa9001 = 0
for element in range(len(sa3)):
	sa5 = sa3[element] % prime
	if sa5 in sa4 and sa9001 != 1:
		print(element + 1)
		sa9001 = 1
	else:
		sa4.append(sa3[element] % prime)
if sa9001 == 0:
	print(-1)


(p, n) = map(int, input().split())
ans = -1
s = set()
for i in range(n):
	nt = int(input())
	if ans == -1 and nt % p in s:
		ans = i + 1
	else:
		s.add(nt % p)
print(ans)


(p, n) = input().split()
(p, n) = (int(p), int(n))
x = []
table = {}
error = 0
for i in range(n):
	x += [int(input())]
for i in range(n):
	try:
		table[x[i] % p]
	except KeyError:
		table[x[i] % p] = 1
	else:
		error = 1
		print(i + 1)
		break
if not error:
	print(-1)


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


(p, n) = map(int, input().split())
l = list(range(p))
c = -1
for i in range(n):
	a = int(input())
	if c == -1:
		a = a % p
		if a not in l:
			c = i + 1
		else:
			l.remove(a)
if c == -1:
	print('-1')
else:
	print(c)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m) = LI()
	d = {}
	ans = inf
	for i in range(m):
		x = I()
		y = x % n
		if y in d:
			ans = min(ans, i + 1)
		d[y] = y
	if ans == inf:
		return -1
	return ans
print(main())


(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())
com = False
l = []
for i in range(n):
	if not l:
		l += [int(input()) % p]
	else:
		k = int(input()) % p
		if not com:
			for j in range(len(l)):
				if k == l[j]:
					com = True
					break
			if not com:
				l += [k]
if len(l) == n:
	print(-1)
else:
	print(len(l) + 1)


(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)


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


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


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


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


pn = list(map(int, input().split()))
p = pn[0]
n = pn[1]
res = [0] * p
inp = []
flag = 0
for i in range(n):
	inp.append(int(input()))
for i in range(len(inp)):
	if res[inp[i] % p] == 0:
		res[inp[i] % p] = 1
	elif res[inp[i] % p] == 1:
		flag = 1
		break
	if flag == 1:
		break
if flag == 1:
	print(i + 1)
else:
	print(-1)


(p, n) = map(int, input().split())
(r, s) = (0, {p})
while r < n:
	x = int(input()) % p
	if x in s:
		break
	r += 1
	s |= {x}
print([-1, r + 1][r < n])


(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)


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


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


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


(p, n) = map(int, input().split())
x = set()
f = -1
for i in range(n):
	inp = int(input()) % p
	if inp not in x:
		x.add(inp)
	elif f == -1:
		f = i + 1
print(f)


lst = []
z = list(map(int, input().split()))
for i in range(z[1]):
	x = int(input())
	if x % z[0] not in lst:
		lst.append(x % z[0])
	else:
		print(len(lst) + 1)
		exit()
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)


import sys
import math
from pprint import pprint
(p, n) = map(int, input().split())
d = {}
for i in range(n):
	x = int(input())
	y = x % p
	if y in d:
		print(i + 1)
		sys.exit()
	d[y] = 1
print(-1)


s = input()
pos = s.find(' ')
p = int(s[0:pos])
n = int(s[pos + 1:])
cnt = [0 for x in range(0, 305)]
for i in range(0, n):
	t = int(input())
	if cnt[t % p] == 1:
		print(i + 1)
		break
	else:
		cnt[t % p] = 1
	if i == n - 1:
		print(-1)
		break


(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)