One test case not passing

#include
#include
#include
using namespace std;
bool compare(pair<int,int> p1,pair<int,int> p2)
{
return p1.second < p2.second;
}
int main()
{
int t,n,s,e;
cin>>t;
vector<pair<int,int>> v;
while(t–)
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s>>e;
v.push_back(make_pair(s,e));
}
sort(v.begin(),v.end(),compare);
}
int res=1;
int fin=v[0].second;
//iterate over remaining
for(int i=1;i<n;i++)
{
if(v[i].first>=fin)
{
fin=v[i].second;
res++;
}
}
cout<<res<<endl;
v.clear();
}

hello @supratik260699
please paste ur code here -> https://ide.codingblocks.com/
and then share the link with me

CB ide is not opening so I have uploaded the screenshot of the program

all the statements from line no ->24 to line no -> 36, should be inside while loop.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.