n,m=map(int,input().split())
a=0
ans=[]
for _ in range(n):
  ans.append('a')
for i in range(m):
  s,c=map(int,input().split())
  if ans[s-1]!='a' and ans[s-1]!=str(c):
    a=-1
  ans[s-1]=str(c)
if ans[0]=='a':
  ans[0]='1'
if ans[0]=='0':
  a=-1
for j in range(n):
  if ans[j]=='a':
    ans[j]='0'
if a==-1:
  print(a)
else:
  print(''.join(ans))