N,M = map(int,input().split())
o = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if o.get(s,-1)==-1:
        o[s]=c
    elif o.get(s,-1)!=-1 and o[s]!=c:
        print(-1)
        break
  else:
    m = [1]+[0]*(N-1)
    for k in o.keys():
        m[k-1]=o[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in m]))
