#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const int inf = 1e9;
const int mo = 998244353;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if (a > b * c)
      cout << "-1\n";
    else {
      long long k = a / (b * d) + 1;
      long long ans = (a + a - (k - 1) * b * d) * (k) / 2;
      cout << ans << endl;
    }
  }
  return 0;
}
