n, m = map(int, input().split())
if n == 0:
  print(-1)
  exit()
a = [-1] * n
for i in range(m):
  p, d = map(int, input().split())
  if a[p - 1] != -1 and a[p - 1] != d:
    print(-1)
    exit()
  else:
    a[p - 1] = d
if a[0] == 0:
  print( -1 )
  exit()
for i in range(n):
  if a[i] == -1:
    a[i] = 0
if a[0] == 0 and n != 1:
  a[0] = 1
 
for i in range(n):
  print(a[i], end = "")
