N,M=map(int,input().split())
s=[];c=[]
num=[0]*N
 
 
for i in range(M):
  array=list(map(int,input().split()))
  s.append(array[0])
  c.append(array[1])
 
for i in range(1000):
  num=str(i)
  if N != len(num):
    continue
  
  for m in range(M):
    if num[s[m]-1] != str(c[m]):
      break

  print(num)
  exit()
    
print(-1)