#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ long long N,M; cin >> N >> M; vector> RL(N); for(int i=0; i<2; i++){ for(int k=0; k> RL.at(k).first; else cin >> RL.at(k).second; } } sort(RL.begin(),RL.end()); long long minlen = 0,maxlen = 0; for(int i=0; i M || maxlen < M){cout << -1 << endl; continue;} M -= minlen; priority_queue,vector>,greater>> Q; for(int i=0; i st; vector use(N); for(int i=0; i