hoge=[]
for i in range(1000):
  hoge.append(str(i))

n,m=map(int,input().split())
huga=[]
for i in range(m):
  a,b=map(int,input().split())
  huga.append([a,b])
for i in range(1000):
  flag=0
  for j in range(m):
    if(len(hoge[i])==n):
      if(hoge[i][huga[j][0]-1]==str(huga[j][1])):
        flag+=1
  if(flag==m):
    print(hoge[i])
    exit()
    
print(-1)
