#include <bits/stdc++.h>
using namespace std;
priority_queue<int>p;
void solve() {
while(!p.empty()) p.pop();
int n, l, m;
cin >> n >> m >> l;
vector<pair<int, int>> h(n);
for (int i = 0; i < n; i++) {
int x,y;
cin >> x >> y;
h[i] = {x, y - x + 2};
}
int x[m],u[m];
for (int i = 0; i < m; i++) {
cin >> x[i] >> u[i];
}
int curr = 1, ans = 0;
for (int i = 0; i < n; i++) {int j=0;
while (j<m && x[j]<h[i].first) {p.push(u[j]);j++;}
while(curr<h[i].second){
if(p.empty()){cout<<-1<<endl;return;}
curr+=p.top();ans++;p.pop();}}
cout << ans << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnByaW9yaXR5X3F1ZXVlPGludD5wOwp2b2lkIHNvbHZlKCkgewoJd2hpbGUoIXAuZW1wdHkoKSkgcC5wb3AoKTsKICAgIGludCBuLCBsLCBtOwogICAgY2luID4+IG4gPj4gbSA+PiBsOwoKICAgIHZlY3RvcjxwYWlyPGludCwgaW50Pj4gaChuKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAJaW50IHgseTsKICAgICAgICBjaW4gPj4geCA+PiB5OwogICAgICAgIGhbaV0gPSB7eCwgeSAtIHggKyAyfTsKICAgIH0KaW50IHhbbV0sdVttXTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgaSsrKSB7CiAgICAgICAgY2luID4+IHhbaV0gPj4gdVtpXTsKICAgICAgICB9CiAgICAgICAKICAgIGludCBjdXJyID0gMSwgYW5zID0gMDsgCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykge2ludCBqPTA7CiAgICAgICAgd2hpbGUgKGo8bSAmJiB4W2pdPGhbaV0uZmlyc3QpIHtwLnB1c2godVtqXSk7aisrO30KICAgICAgICB3aGlsZShjdXJyPGhbaV0uc2Vjb25kKXsKICAgICAgICAJaWYocC5lbXB0eSgpKXtjb3V0PDwtMTw8ZW5kbDtyZXR1cm47fQogICAgICAgIAljdXJyKz1wLnRvcCgpO2FucysrO3AucG9wKCk7fX0KICAgICAgIAogICAgY291dCA8PCBhbnMgPDwgZW5kbDsKfQoKaW50IG1haW4oKSB7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkgewogICAgICAgIHNvbHZlKCk7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=
NAoyIDUgNTAKNyAxNAozMCA0MAoyIDIKMyAxCjMgNQoxOCAyCjIyIDMyCjQgMyA1MAo0IDYKMTUgMTgKMjAgMjYKMzQgMzgKMSAyCjggMgoxMCAyCjEgNCAxNwoxMCAxNAoxIDYKMSAyCjEgMgoxNiA5CjEgMiAxMAo1IDkKMiAzCjIgMgo=
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