#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
ll a[N];
int main()
{
    int T, n, k, ans;
    scanf("%d", &T);
    for (int t = 1; t <= T; t++)
    {
        scanf("%d%d", &n, &k);
        for (int i = 0; i < n; i++) scanf("%lld", a + i);
        ll sum = accumulate(a, a + n, 0ll);
        if (sum % k)
            ans = -1;
        else
        {
            ll tgt = sum / k, cur = 0;
            ans = -1;
            deque<ll> D(a, a + n);
            while (!D.empty())
            {
                int cur = 0;
                while (cur < tgt && !D.empty())
                    cur += D.front(), D.pop_front(), ans++;
                if (cur > tgt) D.push_front(cur - tgt), ans++;
            }
        }
        printf("Case #%d: %d\n", t, ans);
    }
    return 0;
}