#157 c
n,m=map(int,input().split())
num=[-1,-1,-1]
flag=True
for i in range(m):
    x,y=map(int,input().split())
    if x==1 and y==0:
        flag=False

    if num[x-1]!=y and num[x-1]!=-1:
        flag=False
    else:
        num[x-1]=y
ans=""
for i in range(n):
    if i==0 and num[i]==-1:
        num[i]=1
    elif num[i]==-1:
        num[i]=0
    ans+=str(num[i])

if flag:
    print(ans)
else:
    print(-1)
