#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, x, ans;
int _;
int main() {
  cin >> _;
  while (_--) {
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      puts("-1");
      continue;
    }
    x = a / (b * d);
    ans = (a + a - x * b * d) * (x + 1) / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
