Viscous theory for three-layer Rayleigh-Taylor instability