N,M = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(M) ]
ans = [0]*N
for i in range(M):
  ans[ array[i][0] - 1 ] = array[i][1]

if ans[0] == 0 and len(ans) > 1:
  print(-1)
else:
  ans = map(str,ans)
  answer = ''.join(ans)
  print(int(answer))