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

arr=[str(i) for i in range(10**(n-1) if n>1 else 0,10**n)]

for x in arr:
  for i,tmp in enumerate(l):
    s,c=tmp
    if x[s-1]!=str(c):
      break
  else:
    print(x)
    exit()

print(-1)
