Ionospheres and magnetospheres of comets