#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &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");
      continue;
    }
    long long tmp = (a - 1) / (b * d);
    printf("%lld\n", (tmp + 1) * a - (tmp + 1) * tmp / 2 * b * d);
  }
  return 0;
}
