#include <bits/stdc++.h>
using namespace std;
long long n, m, p, c, a[50005], b, d, e;
int main () {
freopen ("verbinden.in", "r", stdin);
freopen ("verbinden.out", "w", stdout);
cin >> n >> m >> p >> c;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= m; i++) {
cin >> b;
if (b == 0) {
cin >> d >> e;
for (int j = d; j <= e; j++) {
int x = 1;
for (int k = 1; k <= a[j]; k++) {
x *= c;
}
a[j] = x;
}
}
if (b == 1) {
cin >> d >> e;
int x = 0;
for (int k = d; k <= e; k++) {
x += a[k];
}
cout << x % p << endl;
}
}
return 0;
}