#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b * c) {
      cout << -1 << endl;
      continue;
    }
    long long ci = a / b / d;
    cout << a * (ci + 1) - ci * (ci + 1) / 2 * b * d << endl;
  }
  return 0;
}
