n,m=map(int,input().split())
sc=[list(map(int, input().split())) for _ in range(m)]
for i in range(10**n):
  ii=str(i)
  if len(ii)==n and all([ii[s-1]==str(c) for s,c in sc]):
    print(ii)
    exit()
print(-1)