#include<bits/stdc++.h>
using namespace std;
bool compare(pair<int,int>p1,pair<int,int>p2){
if(p1.second!=p2.second){
return p1.second<p2.second;
}else{
return p1.first<p2.first;
}
}
int ans(vector<pair<int,int>>v){
sort(v.begin(),v.end(),compare);
int res = 1;
int fin = v[0].second;
for(int i=1;i<v.size();i++){
if(v[i].first>=fin){
res++;
fin = v[i].second;
}
}
return res;
}
int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
vector<pair<int,int>>v;
for(int i=0;i<n;i++){
int x;
int y;
cin>>x;
cin>>y;
v.push_back(make_pair(x,y));
cout << ans(v) << endl;
}
}
}
what is wrong with this code