How to find equations of system dynamics using Lagrange’s approach?

I was able to write the Kinetic Energy and I was also able to write the potential energy of the two springs but how do I write the potential energy of the three masses?

[![enter image description here](https://i.stack.imgur.com/wCAYz.jpg)](https://i.stack.imgur.com/wCAYz.jpg)