#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
ll t;
cin >> t;
while(t--){
ll n, m, k, heap = 1, sum = 0;
cin >> n >> m >> k;
vector<pair<ll, ll> > v(n);
vector<pair<ll, ll> > x(m);
priority_queue<ll> pq;
bool valid = true;
for(int i = 0; i < n; i++){
cin >> v[i].first >> v[i].second;
}
for(int i = 0; i < m; i++){
cin >> x[i].first >> x[i].second;
}
sort(x.begin(), x.end());
int index = 0;
for(int i = 0; i < n; i++){
while(index < m && x[index].first < v[i].second){
if(x[index].first < v[i].first)pq.push(x[index].second);
index++;
}
while(heap < v[i].second - v[i].first + 2){
if(pq.empty()){
cout << "-1\n";
valid = false;
break;
}
heap += pq.top();
pq.pop();
sum ++;
cout << heap << " ";
}
if(!valid)break;
}
if(valid)cout << sum << endl;
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPG1hcD4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxxdWV1ZT4KI2luY2x1ZGU8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmludCBtYWluKCkgewogICAgbGwgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUodC0tKXsKICAgICAgICBsbCBuLCBtLCBrLCBoZWFwID0gMSwgc3VtID0gMDsKICAgICAgICBjaW4gPj4gbiA+PiBtID4+IGs7CiAgICAgICAgdmVjdG9yPHBhaXI8bGwsIGxsPiA+IHYobik7CiAgICAgICAgdmVjdG9yPHBhaXI8bGwsIGxsPiA+IHgobSk7CiAgICAgICAgcHJpb3JpdHlfcXVldWU8bGw+IHBxOwogICAgICAgIGJvb2wgdmFsaWQgPSB0cnVlOwogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAgICBjaW4gPj4gdltpXS5maXJzdCA+PiB2W2ldLnNlY29uZDsKICAgICAgICB9CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG07IGkrKyl7CiAgICAgICAgICAgIGNpbiA+PiB4W2ldLmZpcnN0ID4+IHhbaV0uc2Vjb25kOwogICAgICAgIH0KICAgICAgICBzb3J0KHguYmVnaW4oKSwgeC5lbmQoKSk7CiAgICAgICAgaW50IGluZGV4ID0gMDsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICAgICAgd2hpbGUoaW5kZXggPCBtICYmIHhbaW5kZXhdLmZpcnN0IDwgdltpXS5zZWNvbmQpewogICAgICAgICAgICAgICAgaWYoeFtpbmRleF0uZmlyc3QgPCB2W2ldLmZpcnN0KXBxLnB1c2goeFtpbmRleF0uc2Vjb25kKTsKICAgICAgICAgICAgICAgIGluZGV4Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIHdoaWxlKGhlYXAgPCB2W2ldLnNlY29uZCAtIHZbaV0uZmlyc3QgKyAyKXsKICAgICAgICAgICAgICAgIGlmKHBxLmVtcHR5KCkpewogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgIi0xXG4iOwogICAgICAgICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBoZWFwICs9IHBxLnRvcCgpOwogICAgICAgICAgICAgICAgcHEucG9wKCk7CiAgICAgICAgICAgICAgICBzdW0gKys7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGhlYXAgPDwgIiAiOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKCF2YWxpZClicmVhazsKICAgICAgICB9CiAgICAgICAgaWYodmFsaWQpY291dCA8PCBzdW0gPDwgZW5kbDsKICAgIH0KfQ==
NAoyIDUgNTAKNyAxNAozMCA0MAoyIDIKMyAxCjMgNQoxOCAyCjIyIDMyCjQgMyA1MAo0IDYKMTUgMTgKMjAgMjYKMzQgMzgKMSAyCjggMgoxMCAyCjEgNCAxNwoxMCAxNAoxIDYKMSAyCjEgMgoxNiA5CjEgMiAxMAo1IDkKMiAzCjIgMg==
4
2 5 50
7 14
30 40
2 2
3 1
3 5
18 2
22 32
4 3 50
4 6
15 18
20 26
34 38
1 2
8 2
10 2
1 4 17
10 14
1 6
1 2
1 2
16 9
1 2 10
5 9
2 3
2 2