n,m = map(int, input().split())

temp_ans = ['z']*n
exist = True

for _ in range(m):
  s,c = map(int, input().split())
  
  if temp_ans[s-1]=='z' or temp_ans[s-1]==c:
    temp_ans[s-1]=c
  else:
    exist = False
    break

ans = temp_ans
    
for i, ans_n in enumerate(temp_ans):
  if ans_n=='z':
    if i==0:
      ans[i]=1
    else:
      ans[i]=0
      
if exist==False or ans[0]==0:
  print('-1')
else:
  if n==1:
    print('0')
  else:
    print(*ans, sep='')