#include using namespace std; typedef long long ll; ll gcd(ll a,ll b){ if(b==0){ return a; } return gcd(b,a%b); } int main(){ ll n,m,k;cin >> n >> m >> k; map mb; char c;cin >> c; vector b(m),a(n); for(int i=0;i> b[i]; mb[b[i]%k]++; } for(int i=0;i> a[i]; } ll ans=0; if(c=='+'){ for(int i=0;i v; for(int i=1;i*i<=k;i++){ if(k%i==0){ v.push_back(i); if(i*i!=k){ v.push_back(k/i); } } } for(int i=0;i