[N,M] = [int(s) for s in input().rstrip().split(' ')]
L = [-1 for i in  range(N)]
k = 0
for m in range(M):
  [s_m,c_m] = [int(s) for s in input().rstrip().split(' ')]
  if L[s_m - 1] == -1:
    L[s_m - 1] = c_m
  else: #すでに値が割り振られてる
    if L[s_m - 1] != c_m:
      k = "-1"
      break
#print(L,k)
if k == "-1":
  print("-1")
elif N != 1 and L[0] == 0:
  print("-1")
else:
  for i in range(N):
    if L[i] == -1:
      if i == 0:
        L[i] = 1
      else:
        L[i] = 0
  print("".join([str(s) for s in L]))