#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inf = 1e15;
long double eps = 1e-5;
long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
template <typename T1, typename T2>
bool chkmin(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
bool chkmax(T1& a, T2 b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b * c < a) {
    cout << "-1\n";
    return;
  } else {
    long long k = (a + b * d - 1) / (b * d);
    if (k >= c / d + 1) {
      k = c / d + 1;
    }
    long long delta = k * a - k * (k - 1) / 2 * b * d;
    cout << delta << "\n";
  }
}
signed main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
    cout << "\n";
  }
  return 0;
}
