n,m=map(int,input().split())
x=['0' for _ in range(n)]

for _ in range(m):
  s,c=map(int,input().split())
  
  if x[s-1] != '0' and x[s-1] != str(c):
    print(-1)
    exit()
  else:
    x[s-1] = str(c)
if n==1:
  print(x[0])
elif x[0]=='0':
  x[0]='1'
  print(''.join(x))
else:
  print(''.join(x))