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