n,m = map(int, input().split())

p = [-1]*n
for _ in range(m):
  s,c = map(int, input().split())
  p[s-1] = c
  
if n == 1:
  if p[0] == -1:
    print(0)
  else:
    print(p[0])
  exit()
else:
  if p[0] < 1:
    print(-1)
    exit()
  else:
    for i in range(1, n):
      if p[i] == -1:
        p[i] = 0

ans = ""
for i in p:
  ans += str(i)
print(ans)