#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200010;
int c2[N],c5[N],s2[N],s5[N];
int n, k;
int main ()
{
int T;
cin >> T;
while(T --){
cin >> n >> k;
for(int i = 1; i <= n; i ++)
{
c2[i] = c5[i] = 0;
int x;
cin >> x;
while(x % 2 == 0) c2[i] ++, x /= 2;
while(x % 5 == 0) c5[i] ++, x /= 5;
s2[i] = s2[i - 1] + c2[i];
s5[i] = s5[i - 1] + c5[i];
}
LL res = 0;
for(int i = 1; i <= n; i ++){
int l1 = lower_bound(s2 + i, s2 + 1 + n, s2[i - 1] + k) - s2;
int r1 = upper_bound(s2 + i, s2 + 1 + n, s2[i - 1] + k) - s2;
int l2 = lower_bound(s5 + i, s5 + 1 + n, s5[i - 1] + k) - s5;
int r2 = upper_bound(s5 + i, s5 + 1 + n, s5[i - 1] + k) - s5;
int L = max(l1, l2), R = max(r1, r2);
res += max(0, R - L);
}
cout << res << endl;
}
return 0;
}