import numpy as np
 
n,m = map(int, input().split())
x = np.zeros(n)
ans = 0
setNum = [False, False, False]

for i in range(m):
  s,c = map(int, input().split())
  if setNum[s-1] == False and x[s-1] == 0:
    x[s-1] = c
    setNum[s-1] = True
  elif setNum[s-1] == True and x[s-1] != c:
    ans = -1

if setNum[0] == False:
  x[0] = 1
    
if ans == -1:
  print(ans)
elif x[0] == 0:
  print(-1)
else:
  str_ans = ""
  for i in range(n):
    str_ans = str_ans + str(int(x[i]))
  print(str_ans)