#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long T;
  cin >> T;
  cout.precision(100);
  for (long long t = 0; t < T; t++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b * c < a) {
      cout << -1 << endl;
      continue;
    }
    long long i = a / (b * d);
    cout << a * (i + 1) - b * d * i * (i + 1) / 2 << endl;
  }
  return 0;
}
