import sys
n,m = map(int,input().split())
l = [-1 for _ in range(n)]
for i in range(m):
  s,c = map(int,input().split())
  if(s == 1 and c == 0):
    print(-1)
    sys.exit()
  elif(l[s-1] != -1 and l[s-1] != c):
    print(-1)
    sys.exit()
  else:
    l[s-1] = c
for k in range(n):
  if(l[k] == -1):
    l[k] = 0
if(l[0] == 0):
  l[0] = 1
l=[str(a) for a in l]
l="".join(l)
print(l)
