General formulae for hyperfine structure and endor frequencies