#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
long long n, k, A[maxn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      cout << -1 << endl;
      continue;
    }
    long long e = (a + d * b - 1) / (d * b);
    cout << e * a - (e * (e - 1ll) / 2ll * d * b) << endl;
  }
}
