n,m=map(int,input().split())
sc=[]
dp=[-1]*n
flag=0
for i in range(m):
    s,c=map(int,input().split())
    if dp[s-1]==c or dp[s-1]==-1:
        dp[s-1]=c
    else:
        flag=1
if n>=2 and dp[0]==0:
    flag=1
import sys
if flag==1:
    print(-1)
    sys.exit()
for i in range(n):
    if i==0 and dp[i]==-1:
        dp[i]=1
        continue
    if dp[i]==-1:
        dp[i]=0
print(''.join(map(str,dp)))