import sys
input = sys.stdin.readline
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
    s,c=map(int,input().split())
    s-=1
    if a[s]==-1:
        a[s]=c
    else:
        if a[s]!=c:
            print(-1)
            exit()
if n==1:
    print(a[0])
    exit()

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

ans=""
for i in range(n):
    if a[i]==-1:
        if i==0:
            ans+="1"
        else:
            ans+="0"
    else:
        ans+=str(a[i])
print(ans)
