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

ans = -1
flag = True
for i in range(1, 1000):
    i = str(i)
    for d, x in sc:
        if len(i) != n:
            flag = False
            break
        if i[d-1] != str(x):
            flag = False
    if flag:
        ans = i
        break
    else:
        flag = True

print(ans)