#include <bits/stdc++.h>
using namespace std;
template <class C>
void mini(C &a5, C b5) {
  a5 = min(a5, b5);
}
template <class C>
void maxi(C &a5, C b5) {
  a5 = max(a5, b5);
}
const bool debug = false;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      cout << "-1\n";
      continue;
    }
    long long n = a / (d * b) + 1;
    cout << n * a - n * (n - 1) / 2 * d * b << "\n";
  }
  return 0;
}
