#include <bits/stdc++.h>
using namespace std;
void f() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a > b * c) {
    cout << -1 << endl;
    return;
  }
  long long k = a / (b * d);
  cout << a * (k + 1) - k * (k + 1) / 2 * b * d << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t) {
    f();
    t--;
  }
}
