#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> a, vector<int> b) {
    int cur = 0, answer = 0;
    for (int i = a.size()-1, j = b.size()-1; j+1; j--) {
        while (i+1 && a[i] > b[j]+i) {
            cur += binary_search(b.begin(),b.end(),a[i--]);
        }
        answer = max(answer,cur+int(upper_bound(b.begin(),b.end(),b[j]+i)-b.begin()-j));
    }
    return answer;
}
int main() {
    int t,n,m,c;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        vector<int> x1,y1,x2,y2;
        while (n--) {
            cin >> c;
            if (c < 0) x1.push_back(-c);
            else x2.push_back(c);
        }
        while (m--) {
            cin >> c;
            if (c < 0) y1.push_back(-c);
            else y2.push_back(c);
        }
        reverse(x1.begin(),x1.end());
        reverse(y1.begin(),y1.end());
        cout << solve(x1,y1)+solve(x2,y2) << endl;
    }
}