Help me in solving TAVISUAL problem

My issue

plz help me to understand why we r using the formula c=r-c+l??

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n,c,q;
	    cin>>n>>c>>q;
	    int l,r;
	    for(int j=0;j<q;j++)
	    {
	        cin>>l>>r;
	        if(c>=l&&c<=r)
	        {
	            c=r-c+l;
	        }
	    }
	    cout<<c<<endl;
	}
	return 0;
}

Problem Link: TAVISUAL Problem - CodeChef

@tanmaydwivedi2
c=r-c+l is the formula to calculate the current cup that holds the ball underneath.
just do some rough u will get the intuition.