#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a > b * c) {
    cout << "-1\n";
    return;
  }
  long long l = 0, r = c / d + 1;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (m * d * b < a)
      l = m;
    else
      r = m;
  }
  cout << r * a - l * (l + 1) / 2 * d * b << "\n";
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) solve();
}
