#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t; while (t--) {
int n, m; cin >> n >> m;
int sum = 0;
int ans = n;
for (int i = 0; i < n; i++) {
string s; cin >> s;
if (sum + s.size() > m and ans == n) {
ans = i;
}
sum += s.size();
}
cout << ans << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWlvczo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOwoJaW50IHQ7IGNpbiA+PiB0OyB3aGlsZSAodC0tKSB7CgkJaW50IG4sIG07IGNpbiA+PiBuID4+IG07CgkJaW50IHN1bSA9IDA7CgkJaW50IGFucyA9IG47CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKCQkJc3RyaW5nIHM7IGNpbiA+PiBzOwoJCQlpZiAoc3VtICsgcy5zaXplKCkgPiBtIGFuZCBhbnMgPT0gbikgewoJCQkJYW5zID0gaTsKCQkJfQoJCQlzdW0gKz0gcy5zaXplKCk7CgkJfQoJCWNvdXQgPDwgYW5zIDw8IGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==