Ali has three containers: a 4-liter, a 7-liter, and a 10-liter container. The 10-liter container is full of wine, the other two are empty. Someone wants to buy 5 liters of wine from him. Ali wants to measure out the wine, but only his own containers are available. How can he measure out the wine?

And how can he measure out the wine if he has an 8-liter container instead of a 7-liter container?