n, m = map(int, input().split(' '))
sayi = '*'
for i in range(n-1):
  sayi += '*'
for i in range(m):
  s, t = map(int, input().split(' '))
  if s == 1 and t == 0:
    print(-1)
    break
  if sayi[s-1] == '*' or sayi[s-1] == str(t):
    sayi[s-1] == str(t)
  else:
    print(-1)
    break
for i in range(len(sayi)):
  if sayi[i] == '*':
    if i == 0:
      sayi[i] == '1'
    else:
      sayi[i] == '0'
print(sayi)
    
print()
  