#include <bits/stdc++.h>
using namespace std;
#define Samurai ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
int main(){ Samurai
int _t = 1;
cin >> _t;
for (int i = 1; i <= _t; i++){
int n,m ; cin >> n >> m;
string s = "";
int ans = 0;
bool ok = true;
for(int i=0; i<n; i++){
string x; cin >> x;
if(s.size()+x.size() <= m && ok){
ans++;
s += x;
}
else ok = false;
}
cout << ans << '\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgU2FtdXJhaSBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSwgY291dC50aWUoTlVMTCksIGNpbi50aWUoTlVMTCk7CgppbnQgbWFpbigpeyBTYW11cmFpCiAgICBpbnQgX3QgPSAxOwogICAgY2luID4+IF90OwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gX3Q7IGkrKyl7CiAgICAgICAgaW50IG4sbSA7IGNpbiA+PiBuID4+IG07CiAgICAgICAgc3RyaW5nIHMgPSAiIjsKICAgICAgICBpbnQgYW5zID0gMDsKICAgICAgICBib29sIG9rID0gdHJ1ZTsKICAgICAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspewogICAgICAgICAgICBzdHJpbmcgeDsgY2luID4+IHg7CiAgICAgICAgICAgIGlmKHMuc2l6ZSgpK3guc2l6ZSgpIDw9IG0gJiYgb2spewogICAgICAgICAgICAgICAgYW5zKys7CiAgICAgICAgICAgICAgICBzICs9IHg7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBvayA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IGFucyA8PCAnXG4nOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==