#include <iostream>
#include <vector>
#include <numeric>
#include <map>
using namespace std;
// Function to solve a single test case
long long solve() {
int N;
cin >> N;
vector<long long> A(N);
// Use a map to store frequencies of prefix XOR sums
// Key: prefix XOR sum, Value: count
map<long long, long long> counts;
long long current_xor_sum = 0;
// S[0] is 0. Add it to the count.
counts[0] = 1;
for (int i = 0; i < N; ++i) {
cin >> A[i];
current_xor_sum ^= A[i];
// S[i+1] is current_xor_sum
counts[current_xor_sum]++;
}
// 1. Calculate the total sum of all subarray lengths
// Use (long long) to prevent integer overflow during multiplication
long long n_ll = N;
long long total_length_sum = n_ll * (n_ll + 1) * (n_ll + 2) / 6;
// 2. Calculate the total "discount" (SubtractionTerm)
long long subtraction_term = 0;
// Iterate over all (value, p) pairs in our frequency map
for (auto const& [value, p] : counts) {
// If a value appears p >= 2 times, it contributes to the subtraction
if (p >= 2) {
// The contribution is (p-1) * p * (p+1) / 6, which is C(p+1, 3)
subtraction_term += (p - 1) * p * (p + 1) / 6;
}
}
// 3. The final answer is the total sum minus the discount
return total_length_sum - subtraction_term;
}
int main() {
int T;
cin >> T;
for (int i = 1; i <= T; ++i) {
long long result = solve();
cout << "Case #" << i << ": " << result << endl;
}
return 0;
}