#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define PI 3.14159265358979323846 /* pi */
#define is_pot(n) (n&& !(n&(n-1)))
#define all(v) ((v).begin()),((v).end())
#define int long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define epsilon 1e-9
typedef long long ll;
typedef long double ld;
int dx[]={1, 0, -1, 0};
int dy[]={0, 1, 0, -1};
vector<pair<int, int>> v;
int L, P;
void solve()
{
int n;
cin>>n;
rep(i, n)
{
int d, p;
cin>>d>>p;
v.push_back({d, p});
}
v.push_back({0, 0});
n++;
cin>>L>>P;
sort(all(v));
reverse(all(v));
if(P>=L)
{
cout<<0<<endl;
return;
}
priority_queue<int> pq;
int fuel=P, cnt=0;
fuel-=(L-v[0].first);
if(fuel<0)
{
cout<<-1<<endl;
return;
}
for(int i=0;i<n-1;i++)
{
pq.push(v[i].second);
while(!pq.empty() && fuel<(v[i].first-v[i+1].first))
{
fuel+=pq.top();
pq.pop();
cnt++;
}
if(pq.empty() && fuel<(v[i].first-v[i+1].first))
{
cout<<-1<<endl;
return;
}
fuel-=(v[i].first-v[i+1].first);
}
cout<<cnt<<endl;
}
signed main() {
fastio
int t;cin>>t;while(t--)
solve();
return 0;
}
CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgcmVwKGksIG4pIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiNkZWZpbmUgcmVwMShpLGEsYikgZm9yKGludCBpPWE7aTxiO2krKykKI2RlZmluZSBlbmRsICJcbiIKI2RlZmluZSBQSSAzLjE0MTU5MjY1MzU4OTc5MzIzODQ2ICAvKiBwaSAqLwojZGVmaW5lIGlzX3BvdChuKSAobiYmICEobiYobi0xKSkpCiNkZWZpbmUgYWxsKHY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