f = True
n,m=map(int,input().split())
number = [-1 for i in range(n)]
for i in range(m):
  s,c=list(map(int,input().split()))
  s -= 1
  if s == 0 and c == 0 and n > 1:
    f = False
  elif number[s] == -1:
    number[s] = c
    f = False
  else:
    f = False
if not f:
  print(-1)
elif n == 1:
  if number[0] == -1:
    print(0)
  else:
    print(number[0])
else:
  if number[0] == -1:
    number[0] = 1
  for i in range(1,n):
    if number[i] == -1:
      number[i] = 0
  print(''.join(map(str,number)))