#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
long long a, b, c, d, x, ans;
inline void solve() {
  a = read();
  b = read();
  c = read();
  d = read();
  if (a > b * c) {
    puts("-1");
    return;
  }
  x = min(a / (d * b), (c - 1) / d + 1);
  ans = a * (x + 1) - d * b * (x + 1) * x / 2;
  cout << ans << "\n";
}
signed main() {
  for (long long T = read(); T--;) solve();
  return (0 - 0);
}
