#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]++; } mapA,B; for(int i=0;i>a[i]; ll r = a[i]%k; ans+=mb[(k-r)%k]; } cout<>a[i]; ll g = gcd(k,a[i]); A[g]++; } for(auto itr = A.begin();itr!=A.end();++itr){ for(auto itr1 = B.begin();itr1!=B.end();++itr1){ ll x = itr->first; ll y = itr1->first; if((x*y)%k==0){ ans+=(itr->second)*(itr1->second); } } } cout<