n,m = map(int,input().split())
s = []
c = []
for i in range(m):
  S,C =  map(int,input().split())
  s.append(S)
  c.append(C)
  
num = [1] + [0]*(n-1)
ans = ''
 
for i in range(m):
  if s[i] == 1 and c[i] == 0:
    print(-1)
    exit()
  elif len(set(s)) < len(set(c)):
    print(-1)
    exit()
    
for i in range(m):
  num[s[i]-1] = c[i]
  
for i in range(n):
  ans += str(num[i])
  
print(ans)