input1 = input().split()
N  = int(input1[0])
M = int(input1[1])

list = [0 for i in range(N)]
ans = 0

for i in range(M):
  input2 = input().split()
  s = int(input2[0])
  c = int(input2[1])
  if s == 1 and c == 0:
    ans = -1
  if list[s-1] == 0 or list[s-1] == c:
    list[s-1] = c
  else:
    ans = -1


if list[0] == 0:
  list[0] == 1
  
ans2 = ""

for i in list:
  ans2 = ans2 + str(i)
  
if ans == 0:
  print(int(ans2))
else:
  print(ans)