n, m = map(int, input().split())
ans = 10**(n-1)

judge = [0]*m
for i in range(m):
  judge[i] = [int(x) for x in input().split()]

flag = False
whlie ans < 10**n:
  ans = str(ans)
  for i in range(m):
    if ans[judge[i][0]-1] != judge[i][1]:
      break
    if i == m-1:
      print(int(ans))
      flag = True
      break
  if flag:
    break
  ans = int(ans)+1

if ans == 10**n:
  print(-1)