#include <bits/stdc++.h>
using namespace std;
const int maxl = 3e5 + 10;
int n, m, cnt, tot, cas;
long long ans;
long long a, b, c, d;
bool vis[maxl];
char s[maxl];
inline void prework() { scanf("%lld%lld%lld%lld", &a, &b, &c, &d); }
inline long long calc(long long mid) {
  long long ret = mid * a, ed = (mid - 1) * d, dec;
  dec = (mid - 1) * ed;
  dec -= (mid - 2) * d * (mid - 1) / 2;
  return ret - dec * b;
}
inline void mainwork() {
  if (a > b * c) {
    ans = -1;
    return;
  }
  if (c <= d) {
    ans = a;
    return;
  }
  long long k = a / b / d + 1;
  ans = k * a - k * (k - 1) / 2 * d * b;
}
inline void print() { printf("%lld\n", ans); }
int main() {
  int t = 1;
  scanf("%d", &t);
  for (cas = 1; cas <= t; cas++) {
    prework();
    mainwork();
    print();
  }
  return 0;
}
