#include <bits/stdc++.h>
using namespace std;
int Q;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> Q;
  while (Q--) {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    if (B * C < A) {
      cout << -1 << "\n";
      continue;
    }
    long long l = 1, r = 3000000, ans = 0;
    while (l <= r) {
      long long mid = l + r >> 1;
      if (mid * B * D - A < 0) {
        l = mid + 1;
      } else {
        ans = mid * (mid - 1) / 2 * B * D - A * mid;
        r = mid - 1;
      }
    }
    cout << -ans << "\n";
  }
}
