#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
void solve(){
int n;
cin >> n;
int a = 0, b = 0;
int cnt1 = 0, cnt2 = 0;
vector<int> arr(n);
for(int i = 0; i < n; i++){
cin >> arr[i];
}
for(int i = 0; i < n; i++){
int x;
cin >> x;
if(x == 1 && arr[i] == 1)cnt1++;
else if(x == -1 && arr[i] == -1)cnt2++;
else{
if(x == 0 && arr[i] == 1)a++;
else if(x == 1 && arr[i] == 0)b++;
else if(x == 1 && arr[i] == -1)b++;
else if(x == -1 && arr[i] == 1)a++;
}
}
while(cnt1--){
if(a > b)b++;
else a++;
}
while(cnt2--){
if(a > b)a--;
else b--;
}
cout << min(a, b) << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbjsKCWNpbiA+PiBuOwoJCglpbnQgYSA9IDAsIGIgPSAwOwoJCglpbnQgY250MSA9IDAsIGNudDIgPSAwOwoJCgl2ZWN0b3I8aW50PiBhcnIobik7CgkKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewoJCWNpbiA+PiBhcnJbaV07Cgl9CgkKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewoJCWludCB4OwoJCWNpbiA+PiB4OwoJCWlmKHggPT0gMSAmJiBhcnJbaV0gPT0gMSljbnQxKys7CgkJZWxzZSBpZih4ID09IC0xICYmIGFycltpXSA9PSAtMSljbnQyKys7CgkJZWxzZXsKCQkJaWYoeCA9PSAwICYmIGFycltpXSA9PSAxKWErKzsKCQkJZWxzZSBpZih4ID09IDEgJiYgYXJyW2ldID09IDApYisrOwoJCQll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