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