Shape Programming of a Magnetic Elastica