#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    long long a, b, c, d, e, f, i, j, k, m, n, o, x, y;
    cin >> a >> b >> c >> d;
    if (b * c < a) {
      cout << -1 << "\n";
      continue;
    }
    long long pre = (a - 1) / (b * d) + 1;
    long long ans = pre * a;
    ans -= (((pre * (pre - 1)) / 2) * d * b);
    cout << ans << "\n";
  }
}
