import sys
import numpy as np

n,m = map(int, input().split())

val = [-1]*n

#print(val)

for i in range(m):
  a,b = map(int, input().split())
  if val[a-1]==-1:
    val[a-1] =b
  elif val[a-1]==b:
    continue
  else:
    print(-1)
    sys.exit()

if val[0]==0:
  print(-1)
  sys.exit()
elif val[0]==-1:
  val[0]=1

for i in range(1,n):
  if val[i]==-1:
    val[i]=0
print(*val, sep="")