n, m = gets.split.map(&:to_i)
ans = "0" * n
m.times do
    s, c = gets.split.map(&:to_i)
    if s == 1 && c == 0 && n != 0
        ans = "-1"
        break
    elsif ans[s - 1] == "0"
        ans[s - 1] = c.to_s
    elsif ans[s - 1] != c.to_s
        ans = "-1"
        break
    end
end
if ans[0] == "0" && n != 1
    ans[0] = "1"
end
puts ans.gsub(" ", "0")