n, m = map(int, input().split())
number = [None] * n
flag = True
for _ in range(m):
  s, c = map(int, input().split())
  if number[s-1] is None:
    number[s-1] = c
  elif number[s-1] != c:
    flag = False
if flag:
  if n == 1:
    print(number[0])
  else:
    if number[0] == 0:
      print(-1)
    else:
      if number[0] is None:
        number[0] = 1
      for i in range(1, n):
        if number[i] is None:
          number[i] = 0
      for i in range(n):
        print(number[i], end='')
      print()
else:
  print(-1)