General scheme for stable single and multiatom nanomagnets according to symmetry selection rules