n, m = map(int,input().split())
z = []
for i in range(n):
  z.append(-1)
for i in range(m):
  x1,y1=[int(i) for i in input().split()]
  if z[x1-1] != -1:
    if z[x1-1] != y1:
      print(-1)
      exit(0)
  if x1 == 1:
    if y1 == 0:
      print(-1)
      exit(0)
  z[x1-1] = y1
if n != 1:
  if z[0] == -1:
    z[0] = 1
else:
  if z[0] == -1:
    z[0] = 0
for i in range(1,n):
  if z[i] == -1:
    z[i] = 0
for s in z:
  print(s, end ="")