#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n;
  scanf("%d%d%d", &a, &b, &n);
  for (int i = 0; i < n; i++) {
    int l, t, m, res = -1;
    scanf("%d%d%d", &l, &t, &m);
    int lp = l, rp = (t - a) / b + 1;
    while (lp <= rp) {
      int mp = (lp + rp) / 2;
      if ((long long)m * t < (long long)a * (mp - l + 1) +
                                 (long long)(l + mp - 2) * (mp - l + 1) * b / 2)
        rp = mp - 1;
      else {
        res = mp;
        lp = mp + 1;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
