n,m = map(int,input().split())
ans = [-1] * n
for i in range(m):
    s,c = map(int, input().split())
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()

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

if ans[0] == 0:
    print(-1)
    exit()

print("".join(map(str,ans)))
