n,m=map(int,input().split())
num=[None]*n
for _ in range(m):
  s,c=map(int,input().split())
  s-=1
  if None!=num[s]!=c:
    print(-1)
    exit()
  else:
    num[s]=c
if n>1 and num[0]==0:
  print(-1)
  exit()
if n>1 and num[0] is None:
  num[0]=1
for x in num:
  if x is None:
    x=0
  print(x ,end='')