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

for i in range(N):
  if A[i] == 'a':
    A[i] = 9
Answer = ''.join(map(str,A))

if Answer != 0 and len(Answer) != N:
  Answer = -1

print(Answer)