import sys
N,M=map(int,input().split())
tmp=(['1']+['0' for _ in range(N-1)])
if M==0:
  if N!=1:
    print(''.join(tmp))
    sys.exit()
  else:
    print(0)
    sys.exit()
changed={}
for i in range(M):
  s,c=map(int,input().split())
  if s==1 and c==0:
    print(-1)
    sys.exit()
  if s not in changed.keys():
    tmp[s-1]=str(c)
    changed[s]=c
  else:
    if c==changed[s]:
      pass
    else:
      print(-1)
      sys.exit()
print(''.join(tmp))

