#include <bits/stdc++.h>
using namespace std;
const long long X = 2e6 + 100;
long long ln;
long long pr[X], lst[X];
long long get_sum(long long l, long long r) {
  if (l == 0) return pr[r];
  return pr[r] - pr[l - 1];
}
long long bin(long long l, long long t, long long m) {
  long long right = ln, left = l;
  while (right - left > 1) {
    long long mid = (left + right) / 2;
    if (get_sum(l, mid) <= t * m && lst[mid] <= t) {
      left = mid;
    } else {
      right = mid;
    }
  }
  if (l >= ln) return -2;
  if (!(get_sum(l, l) <= t * m && lst[l] <= t)) {
    return -2;
  }
  return left;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b, n;
  cin >> a >> b >> n;
  lst[0] = a;
  pr[0] = a;
  ln = X;
  for (long long i = 1; i < X; i++) {
    lst[i] = lst[i - 1] + b;
    pr[i] = pr[i - 1] + lst[i];
    if (lst[i] > X) {
      ln = i;
      break;
    }
  }
  for (long long i = 0; i < n; i++) {
    long long l, t, m;
    cin >> l >> t >> m;
    l -= 1;
    cout << bin(l, t, m) + 1 << '\n';
  }
  return 0;
}
