n,m = map(int,input().split())
s = []
c = []
if m == 0:
  if n==1:
    print(0)
    exit()
  elif n==2:
    print(10)
    exit()
  else:
    print(100)
    exit()
 
 
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 n != 1 and s[i] == 1 and c[i] == 0:
    print(-1)
    exit()
  elif n == 1 and s[i] == 1 and c[i] == 0:
    print(-1)
    exit()
for i in range(m-1):
  for j in range(i+1,m):
    if s[i] == s[j] and c[i] != c[j]:
      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)