#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
long long int h;
int n, m, k;
pair<long long int, long long int> tres[100005];
vector<long long int> jump;
priority_queue<pair<long long int, long long int> > tres2;
int mark[100005];
long long int cost[100005];
static const long long int INF = 1e18;
priority_queue<pair<long long int, long long int>,
               vector<pair<long long int, long long int> >,
               greater<pair<long long int, long long int> > >
    pq;
void srch() {
  for (int i = 0; i < k; ++i) cost[i] = INF;
  cost[0] = 0;
  pq.push(make_pair(0, 0));
  while (!pq.empty()) {
    pair<long long int, long long int> cur = pq.top();
    pq.pop();
    if (cost[cur.second] < cur.first) continue;
    for (int i = 0; i < jump.size(); ++i) {
      int to = (cur.second + jump[i]) % k;
      if (cost[to] > cur.first + jump[i]) {
        cost[to] = cur.first + jump[i];
        pq.push(make_pair(cost[to], to));
      }
    }
  }
  for (int i = 0; i < n; ++i)
    if (cost[tres[i].second % k] <= tres[i].second && !mark[i]) {
      mark[i] = 1;
      tres2.push(make_pair(tres[i].first, -i));
    }
}
int main() {
  cin >> h >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> tres[i].first >> tres[i].second;
    --tres[i].first;
    swap(tres[i].first, tres[i].second);
  }
  srch();
  for (int hoge = 0; hoge < m; ++hoge) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      long long int x;
      cin >> x;
      jump.push_back(x);
      srch();
    } else if (t == 2) {
      int x, y;
      scanf("%d%d", &x, &y);
      --x;
      tres[x].first -= y;
    } else {
      while (!tres2.empty()) {
        int top = -tres2.top().second, val = tres2.top().first;
        if (val != tres[top].first) {
          tres2.pop();
          tres2.push(make_pair(tres[top].first, -top));
        } else
          break;
      }
      if (tres2.empty())
        puts("0");
      else {
        printf("%d\n", (int)tres2.top().first);
        tres2.pop();
      }
    }
  }
  return 0;
}
