local read = io.read

local n, m = read("n", "n")
local key_s_t = {}
for i = 1, m do
	local s_i, c_i = read("n", "n")
	if n ~= 1 and s_i == 1 and c_i == 0 then
		print(-1)
		os.exit()
	end
	if key_s_t[s_i] and key_s_t[s_i] ~= c_i then
		print(-1)
		os.exit()
	elseif not key_s_t[s_i] then
		key_s_t[s_i] = c_i
	end
end
for i = 1, n do
	if not key_s_t[i] then
		if i == 1 then
			key_s_t[i] = 1
		else
			key_s_t[i] = 0
		end
	end
end

print(table.concat(key_s_t, ""))
