#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

const int maxn = 2e7 + 5;
int prime[maxn];

void primer(){
    int val = 2e7+1;
    for(int i=0;i<=val;i++){
        prime[i] = i;
    }
    for(int i=2;i*i<=val;i++){
        if(prime[i]==i){
            for(int j=i*i;j<=val;j = j + i){
                if(prime[j]==j){
                    prime[j] = i;
                }
            }
        }
    }
}

int factors(int n){
    int ans = 1;
    while(n!=1){
        int curr = prime[n];
        while(n>1 && n%curr==0){
            //cout<<"n and curr is "<<n<<" "<<curr<<endl;
            n = n/curr;
        }
        ans = ans*2;
    }
    return ans;
}

signed main(void)
{
    fastio;
    int t;
    cin>>t;
    primer();
    unordered_map<int,int>mp1;
    while(t--){
        int c,d,x;
        cin>>c>>d>>x;
        //cout<<"x is "<<x<<endl;
        vector<int>fac;
        int temp = 0;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                fac.push_back(i);
                if((x/i)!=i){
                    fac.push_back(x/i);
                }
            }    
        }
        //cout<<"x is "<<x<<endl;
        int n = fac.size();
        int ans = 0;
        for(int i=0;i<n;i++){
            int k = x/fac[i] + d;
            //cout<<"k is "<<k<<endl;
            if(k%c==0){
                temp = 0;
                int bru = k/c;
                
                if(bru==1){
                    ans+= 1;
                    continue;
                }
                ans+= factors(bru);
                //cout<<"x bru and mp1[bru] is "<<x<<" "<<bru<<" "<<mp1[bru]<<endl;
            }
        }
        cout<<ans<<endl;
    }
}





