#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
const int N = 2e5 + 500;
const int mod = 1e9 + 7;
const int INF = INT_MAX >> 1;
const ll LINF = LLONG_MAX >> 1;
const ld eps = 1e-9;
const int A = 998244353, B = 37;
ll a, b, c, d;
ll solve() {
  cin >> a >> b >> c >> d;
  if (a > b * c) return -1;
  ll k = (a + b * d - 1) / (b * d);
  return -k * k * b * d / 2.L + k * (a + b * d / 2.L);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(20);
  int t;
  cin >> t;
  while (t--) cout << solve() << '\n';
  return 0;
}
