n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

li = [-1] * n

for s,c in sc:
    if li[s-1] == -1 or li[s-1] == c:
        li[s-1] = c
    else:
        print(-1)
        exit()
    if s == 1 and c == 0:
        print(-1)
        exit()

for i in range(n):
    if li[i] == -1:
        if i == 0:
            li[i] = 1
        else:
            li[i] = 0

ans = ''
for i in li:
    ans += str(i)

print(int(ans))
