#include using namespace std; int main() { int p, n, k; bool a[100]; cin >> p; for( int i=0; i> n >> k; a[i] = (1==(n%(k+1))); } for( int i=0; i