Interplay of superconductivity and magnetism in superconductor/ferromagnet structures