#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

//#define endl '\n'
//using db = long double;

using ll = long long;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 998244353;
int solve(vector<int> boxes, vector<int> special) {
    int ans = 0;
    set<int> st(special.begin(),special.end());
    int cnt = 0;
    for(auto x : boxes)cnt += st.count(x);
    for(int i = 0, ptr = 0; i < special.size(); i++) {
        while(ptr < boxes.size() && boxes[ptr] <= special[i] + ptr){
            cnt -= st.count(boxes[ptr]);
            ptr += 1;
        }
        int idx = upper_bound(special.begin(),special.end(), special[i] + ptr-1) - special.begin();
        ans = max(ans,cnt + idx - i);
    }
    return ans;
}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif


    int t;
    cin >> t;

    while(t--) {
        int n, m;
        cin >> n >> m;
        vector<int> leftBoxes, rightBoxes;
        vector<int> leftSpecial, rightSpecial;
        for(int i = 0; i < n; i++) {
            int x;  cin >> x;
            if(x < 0)leftBoxes.push_back(abs(x));
            else rightBoxes.push_back(x);
        }
        for(int i = 0; i < m; i++) {
            int x;  cin >> x;
            if(x < 0)leftSpecial.push_back(abs(x));
            else rightSpecial.push_back(x);
        }
        reverse(all(leftBoxes));
        reverse(all(leftSpecial));
//        cout << solve(leftBoxes,leftSpecial) << endl;
//        cout << solve(rightBoxes,rightSpecial) << endl;
        cout <<  solve(leftBoxes, leftSpecial) + solve(rightBoxes, rightSpecial) << '\n';
    }


  return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
	* DON"T GET STUCK ON ONE PROBLEM
*/
