n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
  s,p=map(int,input().split())
  if a[s-1]!=-1 and a[s-1]!=str(p):
    print(-1)
    break
  else:
    a[s-1]=str(p)
else:
  if a[0]=='0':
    print(-1)
    exit()
  elif a[0]==-1:a[0]='1'
  for i in range(1,n):
    if a[i]==-1:a[i]='0'
  print(''.join(a))