#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;
}

