CP Ships swings to profit