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

for i in range(10**(N-1),10**N):
  n=str(i)
  cnt=0
  for j in range(M):
    if n[sc[j][0]-1]==str(sc[j][1]):
      cnt+=1
    else:
      break
  if cnt==M:
    print(n)
    exit()
print('-1')