https://practice.geeksforgeeks.org/problems/water-connection-problem/0