#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a > b * c) {
    cout << -1 << '\n';
  } else {
    long long k = a / (b * d);
    cout << a * (k + 1LL) - (k * (k + 1LL) / 2) * b * d << '\n';
  }
}
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  int tt;
  cin >> tt;
  while (tt--) solve();
}
