#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;ll K;
struct qq{
ll a;int b,id;
}e[201000];
struct SGT{
ll s1[800100],s2[801000];
void sc(int p){
int l=(p<<1),r=(p<<1|1);
s1[p]=s1[l]+s1[r],s2[p]=s2[l]+s2[r];
}
void build(int p,int l,int r,int z){
if(l==r){
if(z)s1[p]=1,s2[p]=e[l].a;
else s1[p]=s2[p]=0;
return;
}
int mid=(l+r)>>1;build(p<<1,l,mid,z),build(p<<1|1,mid+1,r,z);
sc(p);
}
inline void up(int p,int l,int r,int x,int z){
if(l==r){
if(z)s1[p]=1,s2[p]=e[l].a;
else s1[p]=s2[p]=0;
return;
}
int mid=(l+r)>>1;
if(x<=mid)up(p<<1,l,mid,x,z);
else up(p<<1|1,mid+1,r,x,z);
sc(p);
}
inline ll kth(int p,int l,int r,int k){
if(!k)return 0;
if(l==r)return s2[p];
int mid=(l+r)>>1;
if(k<=s1[p<<1])return kth(p<<1,l,mid,k);
return s2[p<<1]+kth(p<<1|1,mid+1,r,k-s1[p<<1]);
}
}T[2];
#define pb push_back
vector<int>G[201000];
bool vis[201000];
void sol(){
scanf("%d%lld",&n,&K);
for(int i=1;i<=n;i++)scanf("%lld%d",&e[i].a,&e[i].b),vis[i]=0,e[i].id=i,G[i].clear();
sort(e+1,e+n+1,[&](qq x,qq y){return x.a<y.a;});
for(int i=1;i<=n;i++)G[e[i].b].pb(i);
T[0].build(1,1,n,1),T[1].build(1,1,n,0);
ll ns=0;
int ans=0,nt=0,all=0;
for(int i=1;i<=n;i++){
ns+=e[i].a;if(ns>K)break;
nt+=(e[i].b<i);
for(int o:G[i])T[0].up(1,1,n,o,0),T[1].up(1,1,n,o,1),nt+=(o<=i),all++;
int l=nt,r=min(i,all);
while(l<=r){
int mi=(l+r)>>1;
if(T[0].kth(1,1,n,i-mi)+T[1].kth(1,1,n,mi)<=K)
ans=max(ans,mi),l=mi+1;
else r=mi-1;
}
}
printf("%d\n",ans);
if(!ans){puts("0");return;}
T[0].build(1,1,n,1),T[1].build(1,1,n,0);
ns=0,nt=0,all=0;
for(int i=1;i<=n;i++){
ns+=e[i].a;if(ns>K)break;
nt+=(e[i].b<i);
for(int o:G[i])T[0].up(1,1,n,o,0),T[1].up(1,1,n,o,1),nt+=(o<=i),all++;
int l=nt,r=min(i,all),jx=-1;
while(l<=r){
int mi=(l+r)>>1;
if(T[0].kth(1,1,n,i-mi)+T[1].kth(1,1,n,mi)<=K)jx=l,l=mi+1;
else r=mi-1;
}
if(jx==ans){
int st=0;
for(int j=1;j<=n;j++)
if(e[j].b<=i&&st<jx)st++,vis[e[j].id]=1;
assert(st==jx);
st=0;
for(int j=1;j<=n;j++)
if(e[j].b>i&&st<i-jx)st++,vis[e[j].id]=1;
assert(st==i-jx);
printf("%d\n",i);`
for(int j=1;j<=n;j++)if(vis[j])printf("%d ",j);puts("");
return;
}
}
}
int main(){
int T;scanf("%d",&T);while(T--)sol();
return 0;
}