import sys
n,m = map(int,input().split())
l = [-1] * n

for i in range(m):
    s,c = map(int,input().split())
    if l[s - 1] != -1:
        if l[s - 1] != c:
            print(-1)
            exit()
    l[s - 1] = c

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

if l[0] == 0:
    print(-1)
    exit()
elif l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0

for i in l:
    sys.stdout.write(str(i))
print("")