#include #include #include using namespace std; #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define double long double typedef long long ll; typedef pair pii; typedef pair pll; typedef vector vec; typedef vector mat; const ll inf=1e9+7; const ll mod=1e9+7; int main(){ ll n,m,k;cin>>n>>m>>k; vectora(n),b(m); char c;cin>>c; bool f=c=='+'; ll ans; if(f)ans=0; else ans=0; rep(i,m)cin>>b[i]; rep(i,n)cin>>a[i]; if(f){ rep(i,n){ rep(j,m){ ans=(ans+a[i]+b[j])%k; } } }else{ rep(i,n){ rep(j,m){ ans=(ans+a[i]*b[j])%k; } } } cout<