When bulbs are connected in series, the current in each bulb remains same. As power P=i2R, so, the bulb having maximum resistance will appear brightest.
The resistance of a bulb, R=PV2∝P1 (For same V) ∴ The bulb of least power possesses maximum resistance.
Hence, 40W bulb will appear brightest when connected in series with other bulbs.