import sys


input = sys.stdin.readline

def main():
  n, m = map(int, input().rstrip().split())
  digits = [-1] * n
  for i in range(m):
    s, c = map(int, input().rstrip().split())
    if (s > n) or (digits[s-1] != -1 and digits[s-1] != c) or (s == 1 and c == 0):
      print(-1)
      return
    digits[s-1] = c
  
  if digits[0] == -1:
    digits[0] = 1
  print("".join(["0" if _ == -1 else str(_) for _ in digits]))

if __name__ == "__main__":
  main()
