#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  long long a, b, c, d;
  for (int i = 0; i < t; ++i) {
    cin >> a >> b >> c >> d;
    long long k = (a + b * d - 1) / (b * d);
    if (a > b * c) {
      cout << -1 << endl;
    } else {
      cout << k * a - k * (k - 1) * b * d / 2 << endl;
    }
  }
  return 0;
}
