#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); cin>>op; mapmb,cnt; for(int i=0;i>b[i]; mb[b[i]%k]++; } vectord; for(ll i=2;i*i<=k;i++){ if(k%i==0){ ll t = k/i; if(i==t)d.push_back(i); else{ d.push_back(i); d.push_back(t); } } } d.push_back(k); sort(d.begin(),d.end()); for(int i=0;i>a[i]; ll r = a[i]%k; ans+=mb[(k-r)%k]; } cout<>a[i]; ll g = gcd(a[i],k); if(g==1){ ans+=mb[0]; } else{ g = k/g; ans+=cnt[g]; } } cout<