#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const long long Mod = 998244353;
int main() {
  long long a, b, c, d, t;
  cin >> t;
  while (t--) {
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      cout << -1 << endl;
      continue;
    }
    if (c <= d) {
      cout << a << endl;
      continue;
    }
    long long k = a / b / d + 1;
    long long ans = 1ll * k * a - k * (k - 1) / 2 * d * b;
    cout << ans << endl;
  }
}
