n,m = gets.chomp.split.map(&:to_i)
count = 0
ans = Array.new(n,-1)
num_list = []
flag = false
while(true)
    s,c = gets.chomp.split.map(&:to_i)
    if ans[s-1] == -1
        ans[s-1] = c
        num_list.push(s)
    elsif ans[s-1] != c 
        flag = true
        break
    end
    count += 1
    if count == m
        break
    end
end
num = 0
while(true)
    if num == 0
        if ans[num] == -1
            ans[num] = 1
        end
    else
        if ans[num] == -1
            ans[num] = 0
        end
    end
    num += 1
    if num == n
        break
    end
end
if flag || (ans.size >= 2 && ans[0] == 0) 
    print '-1'
else
    ans.each do |a|
        print a.to_i
    end
end