Extremal equation for optimal completely positive maps