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