import sys
n,m = map(int,input().split())
ans = [-1 for i in range(n)]
check = [0 for i in range(n)]
for i in range(m):
    s,c = map(int,input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    else:
        if c == ans[s-1]:
            continue
        else:
            print(-1)
            sys.exit()
    if s-1 == 0:
        if c == 0:
            print(-1)
            sys.exit()
for i in range(1,n):
    if ans[i] == -1:
        ans[i] = 0
if ans[0] == -1:
    ans[0] = 1
ans2 = ''
for i in range(n):
    ans2 += str(ans[i])
print(ans2)