#include #include using namespace std; const int maxn = 200007; struct node { long long location; long long vi; long long count; }a[maxn]; int main() { int T; scanf("%d", &T); while(T--) { int N, M, K, times=0; long long ans = 0; queue Q; scanf("%d%d%d", &N, &M, &K); for(int i=0; i= M ) { a[i].count = times + 1; a[i].location = i; times = 0; Q.push(a[i]); if(Q.size() == K) { node q = Q.front(); Q.pop(); ans += q.count * (N-a[i].location); } } else times += 1; } printf("%I64d\n", ans); } return 0; }