import numpy as np

num = list(map(int,input().split()))

matrix = np.zeros(num[0])
sign_0 = []
sign_1 = []
ans = 0

if num[1] == 0:
  if not matrix[0] == 0:
    ans = 10**(num[0]-1)
  elif matrix[0] == 0:
    ans = -1

elif not num[1] == 0:
  for i in range(0,num[1]):
    temp = list(map(int,input().split()))
    if temp[0] in sign_0 and temp[1] not in sign_1 :
      ans = -1
      break
    else:
      matrix[temp[0]-1] = temp[1]
      sign_0.append(temp[0])
      sign_1.append(temp[1])

  ans = matrix[0]*(10**(num[0]-1))

  if matrix[0] == 0:
    ans = -1

  if not ans == -1:
    for i in range(1,num[0]):
      ans = ans + matrix[i]*(10**(num[0]-1-i))
    
  
print(int(ans))