text: #include<bits/stdc++.h>
  #define ll long long
  #define pb push_back
  #define f(n) for(ll i=0;i<n;i++)
  #define ina for(ll i=0;i<n;i++)cin>>a[i];
  #define all(v) v.begin(),v.end()
  #define YES printf("YES\n")
  #define NO printf("NO\n")
  #define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
  using namespace std;
  //long long bigmod/* (a^p)%m */ ( long long a, long long p, long long m ){long long res = 1;long long x = a;while ( p ){if ( p & 1 ){res = ( res * x ) % m;}x = ( x * x ) % m;p = p >> 1;}return res;}
  //ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; }
  //call manipulated_seive(N) and get prime in prime vector
  //const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
  
  
  
  /*speedup
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize ("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  */
  //Pattern? OEIS
  // prime factorize?? think about 2
  
  
  vector<int>v;
  int a[200003];
  
  int main()
  {
      fastio;
  
          ll t,cs=0; cin>>t;
          while(t--)
          {
              string s;
              ll n;
              cin>>s>>n;
              ll num=0;
  
          for(int i=0;i<s.size();i++)
              {
                  if(s[i]=='-') continue;
                 num=num*10+ (s[i]-'0');
                 num%=n;
              }
  
              if(num==0) printf("Case %lld: divisible\n",++cs);
              else printf("Case %lld: not divisible\n",++cs);
          }
  
      return 0;
  }
  
  
  