#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
#define int long long
pair<pair<int, int>, int> topics[210000];
int n, t;
priority_queue<pair<int, int>> pq;
int suffix[210000];
int check(int k)
{
if (k == 0)
{
return 1;
}
while (!pq.empty())
{
pq.pop();
}
int sum = 0;
for (int i = n; i >= 1; i--)
{
if (i < n)
{
pq.push({topics[i + 1].first.second, i});
sum = sum + topics[i + 1].first.second;
}
int need = max(topics[i].first.first - k, 0ll);
if (need > pq.size())
{
suffix[i] = 9223372036854775807LL;
continue;
}
while (need < pq.size())
{
sum = sum - pq.top().first;
pq.pop();
}
suffix[i] = sum;
}
while (!pq.empty())
{
pq.pop();
}
int now = 1;
sum = 0;
for (int i = k; i <= n; i++)
{
while (now < i)
{
pq.push({topics[now].first.second, now});
sum = sum + topics[now].first.second;
now++;
}
while (pq.size() > k - 1)
{
sum = sum - pq.top().first;
pq.pop();
}
if (sum + suffix[i] + topics[i].first.second <= t)
{
return i;
}
}
return 0;
}
void getans(int k, int p)
{
std::cout << k << "\n";
if (k == 0)
{
std::cout << "0\n";
return;
}
vector<int> ans;
ans.clear();
while (!pq.empty())
{
ans.push_back(topics[pq.top().second].second);
pq.pop();
}
ans.push_back(topics[p].second);
sort(topics + p + 1, topics + n + 1);
for (int i = p + 1; i <= p + (topics[p].first.first - k); i++)
{
ans.push_back(topics[i].second);
}
sort(ans.begin(), ans.end());
std::cout << ans.size() << "\n";
for (auto p : ans)
{
std::cout << p << " ";
}
std::cout << "\n";
}
int main()
{
int q;
cin >> q;
while (q--)
{
std::cin >> n >> t;
for (int i = 1; i <= n; i++)
{
std::cin >> topics[i].first.second >> topics[i].first.first;
topics[i].second = i;
}
sort(topics + 1, topics + n + 1);
int l = 0, r = n;
while (l < r)
{
int mid = (l + r) / 2 + 1;
if (check(mid))
{
l = mid;
}
else
{
r = mid - 1;
}
}
getans(l, check(l));
}
}