(n,m)=gets.split.map(&:to_i)
sc=ARGF.map{|s|s.split.map(&:to_i)}

memo={}
sc.each do|(k,v)|
  if memo[k] == nil || memo[k] == v
    memo[k]=v
  else
    print -1
    exit
  end
end

if memo[1]==0
    print -1
    exit
end

tmp=[0]*n
tmp[0]=1 if n > 1

sc.each{|k,v|
    tmp[k-1]=v
}
print tmp.map(&:to_s).join