#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int q; cin >> q; for (int i = 0; i < q; i++) { long long d, a, b; cin >> d >> a >> b; if (a == 0 && b == 0) { cout << "0" << endl; continue; } long long l, r; a--; l = a / (d - 1) * ((d - 1) * d / 2); long long m = a % (d - 1); l += m * (m + 1) / 2; r = b / (d - 1) * ((d - 1) * d / 2); m = b % (d - 1); r += m * (m + 1) / 2; cout << r - l << endl; } }