a,b=map(int,input().split())
d={}
flag=1
for i in range(b):
  x,y=map(int,input().split())
  if [x,y]==[1,0]:
    if a>1:
      print(-1)
      flag=0
      break
  if x in d:
    if d[x]!=y:
      print(-1)
      flag=0
      break
  d[x]=y
if flag:
  k=['1']+['0']*(a-1)
  for i in d:
    k[i-1]=str(d[i])
  print(''.join(k))