local function query(k, x) io.write(k .. " " .. x .. "\n") io.flush() local ret = io.read("*l") return tonumber(ret) end local n = tonumber(io.read()) local z = 0 if n % 2 == 0 then z = query(2, math.floor(n / 2)) else z = query(1, math.ceil(n / 2)) end while true do if z <= 1 then os.exit() end if z == 2 then io.read() os.exit() end local k, x = io.read():match("(%d+) (%d+)") k = tonumber(k) x = tonumber(x) if k == 1 then z = query(1, n + 1 - x) else z = query(2, n - x) end end