#include <bits/stdc++.h>
using namespace std;
#define el '\n'
// Warning: Disable #define int ...
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
#define int int64_t
// If values can be >= -1e9, S = 1e9 + 1
const int S = 1e12 + 1;
const int z = 1e6;
void run_case(int tc) {
int n;
cin >> n;
vector<int> a(n), c(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> c[i];
}
if (n == 1) {
cout << "0\n";
return;
}
gp_hash_table<int, int, custom_hash> f;
auto upd = [&](int p, int v) {
for (p += 0; p < S; p += p & -p) {
if (f.find(p) == f.end()) {
f[p] = -S;
}
f[p] = max(f[p], v);
}
};
auto get = [&](int p) {
int ans = -S;
for (p += 0; p; p ^= p & -p) {
if (f.find(p) == f.end()) {
f[p] = -S;
}
ans = max(f[p], ans);
}
return ans;
};
upd(z, 0);
vector<int> p(1, a[0]);
for (int i = 1; i < n - 1; i++) {
upd(z + p.back(), get(z + p.back() + a[i] - c[i]) + 1);
p.push_back(p.back() + a[i]);
}
int v = get(z + p.back() + a[n - 1] - c[n - 1]);
if (v >= 0) {
cout << v + 1 << el;
} else {
cout << "-1\n";
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _t = 1;
cin >> _t;
for (int i = 1; i <= _t; i++) {
run_case(i);
}
}