#include using namespace std; #define p 1000000007 _int64 Partition(_int64 n, _int64 k); int main(){ _int64 k, T,n; cin >> T; while (T--){ cin >> n >> k; cout << Partition(n, k) << endl; } return 0; } _int64 Partition(_int64 n,_int64 k){ _int64 i,x,result,l; x = (2 * n - k*(k-1))/(2 * k); if (x <= 0) return -1; l = n - (2 * x + k-1)*k / 2; l = k - l; result = 1; for (i = 1; i <= k; i++){ result = result*x%p; if (i == l) x += 2; else x++; } return result; }