#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>n>>m>>k; vector b(m),a(n); char op;cin>>op; rep(i,m) cin>>b[i]; rep(i,n) cin>>a[i]; auto solveplus=[&](){ map mp; rep(i,n) mp[a[i]%k]++; ll ans=0; rep(i,m){ ll t=(k-b[i]%k)%k; ans+=mp[t]; } cout< ca,cb; rep(i,n) ca[gcd(a[i],k)]++; rep(i,m) cb[gcd(b[i],k)]++; ll ans=0; for(auto pa:ca){ for(auto pb:cb){ if(pa.first*pb.first%k==0){ ans+=pa.second*pb.second; } } } cout<