n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]

for i in range(10**n): #n桁の数字の全パターン
  number =str(i)
  if len(number)==n and all([number[s-1]==str(c) for s,c in sc]):
      print(number) #all すべての要素がTrueならTrue
      exit()
print(-1)
