#include #include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout< A, B, a, b; vector ak; vector ddk; map aa, dk, AK; vector> AA, DK, AAK; string op; int con = 0; cin>>N>>M>>K; cin>>op; B.resize(M); A.resize(N); int k = K; for(int i = 1; i * i <= k; i++){ if(i * i == k) { ddk.push_back(i); }else if(K%i == 0) { ddk.push_back(i); ddk.push_back(K/i); } } for(int i = 2; i * i <= k; i++){ while(k%i == 0){ k /= i; dk[i]++; } } if(k != 1) dk[k]++; for(pair p : dk){ DK.push_back(p); } ak.resize(DK.size()); for(int i = 0; i < M; i++){ cin>>B[i]; } for(int i = 0; i < N; i++){ cin>>A[i]; aa[A[i]%K]++; int ta = A[i], tta = 1; for(int j = 0; j < DK.size(); j++){ for(int z = 0; ta % DK[j].first == 0 && z < DK[j].second; z++){ ta /= DK[j].first; tta *= DK[j].first; } } AK[tta]++; } for(pair p : AK){ AAK.push_back(p); // cout<