废话不多说直接上代码
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long q;
cin >> q;
for (long long i = 0; i < q; i++) {
long long n, a, d;
cin >> n >> a >> d;
long long cnt = 0;
while (d % 2 == 0) {
d /= 2;
cnt++;
}
if (cnt == 0) {
cout << 0;
} else {
long long x = (n - 1) * (pow(2, cnt)-1);
cout << x;
}
cout << "\n";
}
return 0;
}