Photoinduced bending and unbending behavior of liquid-crystalline gels and elastomers