please help me. what’s wrong with my code. It didn’t succeed when i submit.
#include <stdio.h>
#include<math.h>
int main(void) {
// your code goes here
int t,n,q;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&q);
int f,d,i=0,floorCount=0,currentFloor=0;
for(i=0;i<q;i++){
scanf("%d%d",&f,&d);
floorCount+= abs(currentFloor-f) + abs(d-f);
currentFloor = d;
}
printf("%d\n",floorCount);
}
return 0;
}