#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500;
int n, x, y, d[N], m[N];
int main(int argc, char **argv) {
int T;
scanf("%d", &T);
while (T-- != 0) {
scanf("%d%d%d", &n, &x, &y);
for (int i = 0; i < n; ++i)
scanf("%d%d", &d[i], &m[i]);
vector<int> v;
for (int i = 0; i < n; ++i)
if (d[i] <= x && m[i] >= y)
v.push_back(i);
if (v.empty())
puts("-1");
else {
int sol = v[0];
for (size_t i = 1; i < v.size(); ++i)
if (d[v[i]] < d[sol] || (d[v[i]] == d[sol] && m[v[i]] > m[sol]))
sol = v[i];
printf("%d\n", sol + 1);
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmNvbnN0IGludCBOID0gNTAwOwppbnQgbiwgeCwgeSwgZFtOXSwgbVtOXTsKCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikgewoJaW50IFQ7CglzY2FuZigiJWQiLCAmVCk7Cgl3aGlsZSAoVC0tICE9IDApIHsKCQlzY2FuZigiJWQlZCVkIiwgJm4sICZ4LCAmeSk7CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpCgkJCXNjYW5mKCIlZCVkIiwgJmRbaV0sICZtW2ldKTsKCQl2ZWN0b3I8aW50PiB2OwoJCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKQoJCQlpZiAoZFtpXSA8PSB4ICYmIG1baV0gPj0geSkKCQkJCXYucHVzaF9iYWNrKGkpOwoJCWlmICh2LmVtcHR5KCkpCgkJCXB1dHMoIi0xIik7CgkJZWxzZSB7CgkJCWludCBzb2wgPSB2WzBdOwoJCQlmb3IgKHNpemVfdCBpID0gMTsgaSA8IHYuc2l6ZSgpOyArK2kpCgkJCQlpZiAoZFt2W2ldXSA8IGRbc29sXSB8fCAoZFt2W2ldXSA9PSBkW3NvbF0gJiYgbVt2W2ldXSA+IG1bc29sXSkpCgkJCQkJc29sID0gdltpXTsKCQkJcHJpbnRmKCIlZFxuIiwgc29sICsgMSk7CgkJfQoJfQoJcmV0dXJuIDA7Cn0=