local a, b, c, d = io.read("*n", "*n", "*n", "*n") local abmin = math.min(a, b) local edge = {} local offset = 2 local function getnew() offset = offset + 1 return offset - 1 end local function make_chain(spos, size) assert(0 < size) local t = {spos} for i = 2, size do local v = getnew() table.insert(t, v) end return t end if c == 0 then local t0 = make_chain(0, a) local t1 = make_chain(1, b) for i = 2, #t0 do table.insert(edge, {t0[i - 1], t0[i]}) end for i = 2, #t1 do table.insert(edge, {t1[i - 1], t1[i]}) end elseif c == a and c == b then if c == 1 then print(-1) os.exit() end local t = make_chain(0, c - 1) table.insert(edge, {0, 1}) table.insert(edge, {1, 0}) for i = 2, #t do table.insert(edge, {t[i - 1], t[i]}) end elseif c == a then local t0 = make_chain(0, a) local t1 = make_chain(1, b - a) for i = 2, #t0 do table.insert(edge, {t0[i - 1], t0[i]}) end for i = 2, #t1 do table.insert(edge, {t1[i - 1], t1[i]}) end table.insert(edge, t1[#t1], t0[1]) elseif c == b then local t0 = make_chain(1, a) local t1 = make_chain(0, b - a) for i = 2, #t0 do table.insert(edge, {t0[i - 1], t0[i]}) end for i = 2, #t1 do table.insert(edge, {t1[i - 1], t1[i]}) end table.insert(edge, t1[#t1], t0[1]) else local t0 = make_chain(0, a - c) local t1 = make_chain(1, b - c) for i = 2, #t0 do table.insert(edge, {t0[i - 1], t0[i]}) end for i = 2, #t1 do table.insert(edge, {t1[i - 1], t1[i]}) end local cpos = getnew() table.insert(edge, {t0[#t0], cpos}) table.insert(edge, {t1[#t1], cpos}) local tc = make_chain(cpos, c) for i = 2, #tc do table.insert(edge, {tc[i - 1], tc[i]}) end end if d < #edge then print(-1) else print(offset .. " " .. #edge) for i = 1, #edge do print(edge[i][1] .. " " .. edge[i][2]) end end