#include <iostream>
#include <vector>
#include <algorithm>
bool solve(int N, int M, std::vector<int>& A, std::vector<int>& B) {
std::sort(A.begin(), A.end());
std::sort(B.begin(), B.end());
int cnt = 0;
// Adjust A and calculate the count of adjustments
for (int i = 0; i < N; ++i) {
if (A[i] > 1 || (i == 0 && A[i] == 1)) {
cnt++;
A[i]--;
}
}
int a = 0; // Index pointer for A
for (int b = 0; b < M; ++b) {
// Move pointer 'a' while A[a] <= a + b
while (a < N && A[a] <= a + b) {
a++;
}
// Try to reduce B[b] using the available count
while (cnt > 0 && a + b < B[b]) {
B[b]--;
cnt--;
}
// If B[b] cannot be satisfied, return false
if (a + b < B[b]) {
return false;
}
}
return true;
}
int main() {
int T;
std::cin >> T;
while (T--) {
int N, M;
std::cin >> N >> M;
std::vector<int> A(N), B(M);
for (int i = 0; i < N; ++i) std::cin >> A[i];
for (int i = 0; i < M; ++i) std::cin >> B[i];
if (solve(N, M, A, B)) {
std::cout << "Yes" << std::endl;
} else {
std::cout << "No" << std::endl;
}
}
return 0;
}