N,M = list(map(int,input().split()))
A = ['a']*N
for i in range(M):
  s,c = list(map(int,input().split()))
  if A[s-1] != 'a' and A[s-1] != str(c):
    print('-1')
    exit()
  else:
    A[s-1] = str(c)
if A[0] == '0' and len(A) != 1:
  print('-1')
  exit()
elif A[0] == 'a' and len(A) != 1:
  A[0] == '1'
for i in range(N):
      if A[i] == 'a':
        A[i] = '0'
print(''.join(A))