n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(10**n):
  x=str(i)
  if len(x)<n:pass
  else:
    c=0
    for i in range(m):
      if x[l[i][0]-1]==str(l[i][1]):
        c+=1
    if c==m:
      print(x)
      quit()
print(-1)