S = []
N,M = [int(i) for i in input().split(" ")]

for  _ in range(M):
    s,c = input().split(" ")
    S.append([int(s)-1,c])

start = N if N == 1  else 10**(N-1)
ans = -1
for num in range(start,1000):
    flag = True
    s_num = str(num)
    for s in S:
        if (s_num[s[0]] != s[1]):
            flag = False
            break
    if (flag):
        ans = num
        break

print (ans)