#include <bits/stdc++.h>
using namespace std;
int vis[120000], n, fron[120000], bac[120000], dp[120000], a, b;
void dpf() {
  bac[0] = -1200000;
  fron[n] = 1200000;
  for (int i = 0; i <= n; i++) {
    if (vis[i] == 0) {
      if (i) bac[i] = bac[i - 1];
    } else
      bac[i] = i;
  }
  for (int i = n; i >= 0; i--) {
    if (vis[i] == 0) {
      if (i < n) fron[i] = fron[i + 1];
    } else
      fron[i] = i;
  }
}
void make(int start, int fin, int id) {
  for (int i = start; i <= fin; i++) {
    vis[i] = id;
  }
  dpf();
}
int call1(int j, int id) {
  int start = -1, ans = -1;
  for (int i = 0; i <= n; i++) {
    if (vis[i]) {
      start = -1;
      continue;
    }
    if (start == -1 && (i - bac[i]) >= a) {
      start = i;
      continue;
    }
    if (start == -1) continue;
    if ((fron[i] - i) >= b && (i - start) == j) {
      make(start, i, id);
      ans = start;
      break;
    }
  }
  return ans;
}
void ers(int id) {
  for (int i = 0; i <= n; i++) {
    if (vis[i] == id) vis[i] = 0;
  }
  dpf();
}
int main() {
  int i, j, k = 0, l, m, q, start = -1, endo;
  cin >> n >> a >> b >> q;
  dpf();
  for (i = 1; i <= q; i++) {
    cin >> m >> j;
    if (m == 1) {
      k++;
      cout << call1(j, i) << endl;
    } else
      ers(j);
  }
}
