#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
int n, x, y, idx, d, m, mn, mx;
int t;
scanf("%d", &t);
while(t--) {
scanf("%d%d%d", &n, &x, &y);
idx = -1, mn = 1e9, mx = -1;
for(int i=0; i<n; ++i) {
scanf("%d%d", &d, &m);
if(d <= x && m >= y) {
if(d < mn || mn == d && m > mx) {
idx = i + 1;
mn = d;
mx = m;
}
}
}
printf("%d\n", idx);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbiwgeCwgeSwgaWR4LCBkLCBtLCBtbiwgbXg7CglpbnQgdDsKCXNjYW5mKCIlZCIsICZ0KTsKCgl3aGlsZSh0LS0pIHsKCQlzY2FuZigiJWQlZCVkIiwgJm4sICZ4LCAmeSk7CgkJaWR4ID0gLTEsIG1uID0gMWU5LCBteCA9IC0xOwoJCWZvcihpbnQgaT0wOyBpPG47ICsraSkgewoJCQlzY2FuZigiJWQlZCIsICZkLCAmbSk7CgkJCWlmKGQgPD0geCAmJiBtID49IHkpIHsKCQkJCWlmKGQgPCBtbiB8fCBtbiA9PSBkICYmIG0gPiBteCkgewoJCQkJCWlkeCA9IGkgKyAxOwoJCQkJCW1uID0gZDsKCQkJCQlteCA9IG07CgkJCQl9IAoJCQl9CgkJfQoJCXByaW50ZigiJWRcbiIsIGlkeCk7Cgl9CglyZXR1cm4gMDsKfQ==