I\'m trying to improve the performance of my code but I\'m stuck at a point with 4 nested for loops. The below code is the representation of what I\'m doing in the loops and