#include <bits/stdc++.h>
using namespace std;
int t, a, b, c, d, n;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a > (long long)b * c) {
      puts("-1");
      continue;
    }
    n = a / b / d;
    cout << (long long)(a + a - (long long)d * b * n) * (n + 1) / 2 << endl;
  }
  return 0;
}
