p-electron magnetism in CdS doped with main group elements