
def main():
  n, m = map(int, input().split(' '))

  if m == 0:
    print(10 ** (n - 1))
    return

  num_list = [0] * n
  done_list = [-1] * n

  for _ in range(m):
    s, c = map(int, input().split(' '))

    if (s == 1 and c == 0) or (done_list[s - 1] != -1 and done_list[s - 1] != c):
      print(-1)
      exit()

    num_list[s - 1] = c
    done_list[s - 1] = c

  if num_list[0] == 0:
    num_list[0] = 0 if n == 1 else 1

  print("".join(map(str, num_list)))

main()
