#include <bits/stdc++.h>
using namespace std;
int a, b, n;
long long solve(long long l, long long t, long long m) {
  if (a + (l - 1) * b > t) return -1;
  long long left = l, right = 1e7, r;
  while (left < right) {
    r = (left + right + 1) >> 1;
    if ((r - l + 1) * (2 * a + b * (l + r - 2)) <= m * t * 2 and
        a + (r - 1) * b <= t)
      left = r;
    else
      right = r - 1;
  }
  return left;
}
int main() {
  cin >> a >> b >> n;
  for (int i = 0; i < n; i++) {
    long long l, t, m;
    cin >> l >> t >> m;
    cout << solve(l, t, m) << endl;
  }
}
