#include<bits/stdc++.h> using DB = double; const DB eps = 1e-6; constint N = 1e4 + 100, INF = 0x3f3f3f3f; int n; DB m, f; structNode{ DB f, m; int id; } a[N]; std::vector<int> ans, as; intcmp(DB x, DB y) { if (fabs(x - y) < eps) return0; return x > y ? 1 : -1; } boolchk(DB x) { as.clear(); DB t = m * x - f, sum = 0; for (int i = 1; i <= n; ++i) if (cmp(a[i].f - a[i].m * x, 0) == 1) { as.push_back(a[i].id); sum += a[i].f - a[i].m * x; if (cmp(sum, t) != -1) break; } if (cmp(sum, t) != -1) { ans = as; returntrue; } returnfalse; } intmain() { scanf("%lf %lf %d", &f, &m, &n); for (int i = 1; i <= n; ++i) scanf("%lf %lf", &a[i].f, &a[i].m), a[i].id = i; std::sort(a + 1, a + n + 1, [&](Node x, Node y){ return x.f * y.m > y.f * x.m; }); DB l = 0, r = INF, mid; while (cmp(l, r) == -1) { mid = (l + r) / 2; if (chk(mid)) l = mid; else r = mid; } std::sort(ans.begin(), ans.end()); if (!ans.size()) puts("NONE"); elsefor (int i : ans) printf("%d\n", i); return0; }