#include<bits/stdc++.h>
using namespace std;
#define LL long long
int ans(vector<int> u, vector<int> v) {
    int cur = 0, mx = 0, n = u.size(), m = v.size();
    for(int i = n-1, j = m-1; j >= 0; j--) {
        while(i >= 0 && u[i] > v[j] + i) {
            if(binary_search(v.begin(), v.end(), u[i])) cur++;
            --i;
        }
        mx = max(mx, cur + (int)(upper_bound(v.begin(), v.end(), v[j] + i) - v.begin() - j));
    }
    return mx;
}
void solve() {
    int n, m, x;
    vector<int> a, b, c, d;
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        cin >> x;
        (x < 0 ? a : c).push_back((x < 0 ? -x : x));
    }
    for(int i = 0; i < m; i++) {
        cin >> x;
        (x < 0 ? b : d).push_back((x < 0 ? -x : x));
    }
    sort(a.begin(), a.end()), sort(b.begin(), b.end());
    cout << ans(a, b) + ans(c, d) << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int tt;
cin >> tt;
while(tt--)
    solve();
return 0;
}
