#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair P; typedef pair Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } int main(void){ int n,m; ll k; cin>>n>>m>>k; char op; vectora(n),b(m); ll sum = 0; cin>>op; mapmb; for(int i=0;i>b[i]; mb[b[i]%k]++; } if(op=='+'){ ll ans = 0; for(int i=0;i>a[i]; ll r = a[i]%k; ans+=mb[k-r]; } cout<>a[i]; ll g = gcd(a[i],k); if(g==1){ ans+=mb[0]; } else{ g = k/g; ll x=1; while(g*x<=k){ if(g*x!=k)ans+=mb[g*x]; else ans+=mb[0]; x++; } } } cout<