#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int MOD = 1000000007;
const int INF = 1000000010;
mt19937 gen(41);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      cout << "-1\n";
      continue;
    }
    long long k = a / (b * d);
    cout << a * (k + 1ll) - (k * (k + 1ll) / 2ll) * b * d << '\n';
  }
}
