The solution proposed here will not scale in general, but it is still nice for limited usage scenarios.…