#include <bits/stdc++.h>
int main() {
  long n, i, a[100000], b[100000], c[100000], d[100000];
  long long x, y, z;
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%ld %ld %ld %ld", &a[i], &b[i], &c[i], &d[i]);
  }
  for (i = 0; i < n; i++) {
    if (a[i] > (long long)b[i] * c[i]) {
      printf("-1 \n");
    } else {
      if (a[i] == (long long)b[i] * c[i] && d[i] >= c[i]) {
        printf("%ld \n", a[i]);
      } else {
        if (a[i] == b[i] * c[i] && d[i] < c[i]) {
          x = (long long)a[i] * (c[i] / d[i] + 1) -
              (long long)b[i] * d[i] * (c[i] / d[i]) * (c[i] / d[i] + 1) / 2;
          printf("%lld \n", x);
        } else {
          if (a[i] < (long long)b[i] * c[i] && a[i] <= b[i]) {
            printf("%ld \n", a[i]);
          } else {
            if (a[i] < (long long)b[i] * c[i] && a[i] > b[i] && d[i] >= c[i]) {
              printf("%ld \n", a[i]);
            }
            if (a[i] < (long long)b[i] * c[i] && a[i] > b[i] && d[i] < c[i]) {
              x = (long long)((a[i] / b[i]) / d[i] + 1) * a[i] -
                  (long long)((a[i] / b[i]) / d[i] + 1) *
                      (long long)((a[i] / b[i]) / d[i]) * b[i] * d[i] / 2;
              printf("%lld \n", x);
            }
          }
        }
      }
    }
  }
}
