#include <iostream>
#include <string>
using namespace std;
int main() {
string num;
string::iterator it;
int T, ca;
long long carry, b;
while(cin >> T) {
ca = 1;
while(T--) {
cin >> num >> b;
it = num.begin();
carry = 0;
if(num[0] == '-') it++;
for(; it != num.end(); it++) {
carry = carry * 10 + *it - '0';
carry %= b;
}
if(!carry) cout << "Case" << " " << ca++ << ": divisible" << endl;
else cout << "Case" << " " << ca++ << ": not divisible" << endl;
}
}
return 0;
}