#include <bits/stdc++.h>
int read() {
  static int c, x;
  while ((c = getchar()) < 48) {
  }
  x = c & 15;
  while ((c = getchar()) >= 48) x = x * 10 + (c & 15);
  return x;
}
int main() {
  for (int T = read(); T--;) {
    const int a = read(), b = read(), c = read(), d = read();
    if (a > 1ll * b * c) {
      puts("-1");
      continue;
    }
    const int t = (a - 1) / b / d;
    printf("%lld\n", 1ll * a * (t + 1) - (1ll * t * (t + 1) >> 1) * b * d);
  }
  return 0;
}
