#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define print(a) for(auto x : a) cout << x << " "; cout << endl
inline int power(int a, int b) {
int x = 1;
while (b) {
if (b & 1) x *= a;
a *= a;
b >>= 1;
}
return x;
}
const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;
//_ ***************************** START Below *******************************
//_ Intuition :
//* Bruteforce :
//* Iterate each query from q1 to qn
//* Build State[n] array of 0's and fill it with queries [q0 to qi] in O(q) time
//* Iterate each segment and find out any segments with 1's > segLen/2 in O(m) time
//* To check 1's in Seg_i in O(1) time,
//* Build prefixSum[] of State[] to get sum of range [l,r] in O(1)
//* This takes O(n) time
//* Hence T.C. == O(q * (q+m+n))
//* We can notice that once Seg becomes beautiful for qi query,
//* It remains beautiful for qi+1 to qn queries also
//* Monotonic Predicate func Property
//* Hence we can use Binary Search on Outer Linear Search
//* logq * ( q + m + n)
//_ T.C. :
//* O(logq * (q + m + n))
vector<pair<int,int>> segs;
vector<int> q;
int n;
int m;
int k;
bool isPossible(int mid){
vector<int> temp(n, 0);
for(int i=0; i<=mid; i++){
int idx = q[i];
temp[idx-1] = 1;
}
vector<int> prefix(n+1, 0);
for(int i=0; i<n; i++){
prefix[i+1] = prefix[i] + temp[i];
}
for(int i=0; i<m; i++){
int l = segs[i].first;
int r = segs[i].second;
int ones = prefix[r] - prefix[l-1];
if(ones > (r-l+1)/2) return true;
}
return false;
}
int consistency(){
int ans = INF;
int s = 0, e = k-1;
while(s<=e){
int mid = s + (e-s)/2;
if(isPossible(mid)){
ans = min(ans, mid);
e = mid-1;
}
else{
s = mid+1;
}
}
if(ans == INF) return -1;
return ans+1;
}
void solve() {
cin>>n >> m;
segs.resize(m);
for(int i=0; i<m; i++){
int x, y;
cin >> x >> y;
segs[i] = {x,y};
}
cin >> k;
q.resize(k);
for(int i=0; i<k; i++) cin >> q[i];
cout << consistency() << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}