#include using namespace std; int T, n, ans, a[2010]; long long b[2010], f[2010][2010]; int main() { scanf("%d", &T); while (T--) { memset(f, -1, sizeof(f)); scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) { scanf("%lld", &b[i]); b[i] += b[i - 1]; } f[0][0] = ans = 0; for (int i = 1; i <= n; ++i) { f[i][0] = 0; for (int j = 1; j <= i; ++j) { f[i][j] = f[i - 1][j]; if (f[i - 1][j - 1] != -1 && f[i - 1][j - 1] + a[i] <= b[i]) if (f[i][j] == -1 || f[i - 1][j - 1] + a[i] <= f[i][j]) f[i][j] = f[i - 1][j - 1] + a[i]; if (f[i][j] != -1) ans = max(ans, j); } } printf("%d\n", ans); } return 0; }