#abc157c
n,m=map(int,input().split())
sc=[]
for i in range(m):
 s,c=list(map(int,input().split()))
 sc.append([s,c])
for i in range(10**n):
 st=str(i)
 if len(st)!=n:
  continue
 if all([st[s-1]==str(c) for s,c in sc]):
  print(st)
  exit()
print(-1)
