#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.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) << endl;
      continue;
    }
    long long k = (a / (d * b));
    cout << (a * (k + 1)) - (d * b * k * (k + 1) / 2) << endl;
  }
  return 0;
}
