Hybrid quantum circuit consisting of a superconducting flux qubit coupled to a spin ensemble and a transmission-line resonator