#include <bits/stdc++.h>
using namespace std;
const int N = 7;
const int INF = 1e9 + 7;
long long T;
int main() {
  scanf("%lld", &T);
  while (T--) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if (a > b * c) {
      puts("-1");
      continue;
    }
    long long h = a / b;
    long long q = h / d + 1;
    long long p = a * q - q * (q - 1) * d * b / 2;
    printf("%lld\n", p);
  }
  return 0;
}
