# coding: utf-8
N,M=map(int,input().split())
ansl=[None for i in range(N)]
flg=True

for i in range(M):
    s,c=map(int,input().split())
    if ansl[s-1]==None:
        ansl[s-1]=str(c)
    else:
        if ansl[s-1]!=str(c):
            flg=False

for i in range(N):
    if ansl[i]==None:
        if i==0:
            ansl[i]="1"
        else:
            ansl[i]="0"

if ansl[0]=="0" and N!=0:
    flg=False

ans=""

for i in range(N):
    ans+=ansl[i]
if flg:
    print(int(ans))
else:
    print(-1)
