#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 10;   long long A, B, N;   long long l, t, m;   int main() {     cin >> A >> B >> N;     for (int i = 1; i <= N; i++) {       cin >> l >> t >> m;       if (t < A + (l - 1) * B) {         cout << -1 << endl;         continue;       }       long long L = 1, R = 10000000, M;       while (L <= R) {         M = (L + R) / 2;         if ((2 * A + (l + M - 2) * B) * (M - l + 1) > t * m * 2)           R = M - 1;         else           L = M + 1;       }       cout << min(R, (t - A + B) / B) << endl;     }     return 0;   }   