#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  scanf("%lld", &t);
  while (t--) {
    long long a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    if (a > b * c)
      printf("-1\n");
    else {
      long long t = (a - 1) / b / d;
      long long ans = a * (t + 1) - (t + 1) * t / 2 * b * d;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
