Phase transitions in the gas of bags