To solve these tasks, it is crucial to track the color of each item and the position of each item in the row. Therefore, the variables tracking would work well to solve these problems. So the answer is Variables tracking.