This is not a homework question. Instead, I want to touch on the concepts of comparing height changes for a fluid in a restricted medium, such as this container, with other simple containers like that of a cylinder. Here's a problem that asks a question touching those concepts. If you don't feel like giving the exact answer, you don't have to. But my aim is to get a starting point, or something conceptual that can be told would be extremely helpful to me.

> Both the containers contain liquid up to the same height, and they're connected by a tube. Assume that the shapes and sizes of the containers are not affected by the heating of liquid.
>
> If the liquid in the container $A$ is heated, which direction should the water flow in?
>
> And similarly, if the container $B$ is heated, which direction will the liquid flow then?
>
>Assume that heat doesn't affect the containers.
>
>![1]

What I've been thinking is this: Consider a cylindrical container containing a liquid. It is easy to see that weight of liquid divided by the area of the base of the container is pressure at the bottom. Since neither the area nor the weight of the liquid changes on heating, the pressure remains constant. And since $P = \rho g h$, it means that here $\rho h$ remained constant, density decreases, but height increases.

But for containers that aren't shaped like cylinders, I'm facing problems to see how the change in height would react with the change in density. Because this is not free expansion, and is restricted by the container too, I thought, it wouldn't be correct to assume the change in height as a linear relation for both the containers. But if I can compare the required change in height, to keep the pressure same, against the actual change in height for each container, then I'll get the result to whether the pressure in the container will reduce or increase. But how can I approach doing that? I'm also unsure about the answer to this problem, although the answer given is that in both cases, liquid flows from $B$ to $A$.

  [1]: https://i.sstatic.net/26chN2KM.png