N,M = map(int,input().split())
A = ['a']*N
for _ in range(M):
  s,c = map(int,input().split())
  if A[s-1] !='a' and A[s-1] != c:
    print(-1)
    exit()
  else:
    A[s-1] = c

for i in range(N):
  if A[0] == 'a':
    A[0] = 1
  elif A[i] == 'a':
    A[i] = 0
Answer = ''.join(map(str,A))
Answer = str(int(Answer))
if Answer != '0' and len(Answer) != N:
  Answer = -1

print(Answer)
