n, m = map(int, input().split())
sc = []
flag = False
ans = ''

for _ in range(m):
    s, c = map(int, input().split())
    sc.append([s, c])

for i in range(1, 1000):
    i = str(i)
    if len(i)<n:
        continue

    for s, c in sc:
        if i[s-1]==str(c):
            flag = True
        else:
            flag = False
            break

    if flag:
        ans = i
        break

if ans:
    print(int(ans))
else:
    print(-1)