const _q = Math.min(r - 1, Math.floor((a[ai] * r + a[ai + 1]) / b[bi]));