N, M = map(int, input().split())
num = ['']*N
valid = True
#create number from input
for i in range(M):
  s, c = map(int, input().split())
  if (num[s-1] == ''):
    num[s-1] = c
  elif (num[s-1] != c):
    valid = False
    break
#check whether 0 is at front
if (N > 1):
  if (num[0]==0):
    valid = False
  
if valid:
  #fill the blank parts
  for i in range(N):
    if (num[i] == ''):
      if (i == 0):
        num[i] = 1
      else:
      	num[i] = 0
  #convert list to number
  answer = 0
  for i in range(N):
    answer *= 10
    answer += num[i]
  print(answer)
else:
  print(-1)
  
