n,m=map(int,input().split())
l=[]
l1=[]
flag=0

for i in range(n):
  l.append(0)
  l1.append(0)

for i in range(m):
  a,b=map(int,input().split())
  
  if l1[a-1]!=0:
    flag=1
    break

  else:
    l[a-1]=b
    l1[a-1]=1
 # print(l1[a-1],l[a-1])

s=str()
for i in range(n):
  s+=str(l[i])

#print(s,flag)
if n==1 and flag==0:
  print(s)
elif flag==0 and s[0]!='0':
  print(s)
else:
  print(-1)
    