#include <iostream>
using namespace std;
int t, m, n;
int f(int m, int n)
{
if (m == 0)
return 1;
if (n == 1)
return 1;
if (n > m)
return f(m, m);
return f(m, n - 1) + f(m - n, n);
}
int main()
{
cin >> t;
while (t--)
{
cin >> m >> n;
cout << f(m, n) << '\n';
}
return 0;
}