#include using ll = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n,m,k; string op; cin >> n >> m >> k >> op; ll a,b,sa{0},sb{0},res; for (int i=0;i> b; sb+=b; } for (int i=0;i> a; sa+=a; } if (op == "+") { res=(sa*m+sb*n) % k; } else { res=((sa % k)*(sb % k)) % k; } cout << res << "\n"; return 0; }