n, m = map(int, input().split())

li = [0]*n

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

if li[0]==0:
    li[0]=1

for i in range(n):
    print(li[i], end="")