#LIFTME ERROR

#include
using namespace std;

int main() {
// your code goes here
long t,q,n,fi,di,floort,update,sum=0,a,b;
cin >> t;
while(t–)
{
cin >> n >> q;
floort=0;
update=0;
sum=sum+q;
while(q–)
{
cin >> fi >> di;
if((fi != di) && (fi >= 0) && (di >= 0) && (fi <= n) && (di <= n) && sum <= 100000 && t>=1 && t<=250 && n>=1 && n<=1000000 && q>=1 && q<=100000)
{
if(fi>=update)
a=fi-update;
else
a=update-fi;
if(fi>di)
b=fi-di;
else
b=di-fi;
floort=floort+a;
floort=floort+b;
update=di;
}
}
cout << floort << endl;
}
return 0;
}

I am a beginner and I am not able to debug my code,I followed all constraints and checked it multiple times(till end of contest) but not able to get it…Today’s cookoff was my first contest…I welcome all types of help and criticism which can optimize my code better and help me in future

Thank you