#include <bits/stdc++.h>
using namespace std;
int L, b, f;
int len[100], pos[100], n;
vector<int> cand;
int main() {
  scanf("%d%d%d%d", &L, &b, &f, &n);
  for (int i = 0; i < (int)(n); ++i) {
    int qt;
    scanf("%d", &qt);
    if (qt == 1) {
      scanf("%d", len + i);
      if (len[i] <= L) {
        cand.push_back(0);
      }
      for (int j = 0; j < (int)(i); ++j)
        if (pos[j] != -1 && pos[j] + len[j] + b + len[i] <= L) {
          cand.push_back(pos[j] + len[j] + b);
        }
      sort(cand.begin(), cand.end());
      pos[i] = -1;
      for (int x : cand) {
        int from = x - b;
        int to = x + f + len[i];
        bool ok = true;
        for (int j = 0; j < (int)(i); ++j)
          if (pos[j] != -1 && from < pos[j] + len[j] && pos[j] < to) {
            ok = false;
            break;
          }
        if (ok) {
          pos[i] = x;
          break;
        }
      }
      cand.clear();
      printf("%d\n", pos[i]);
    } else {
      pos[i] = -1;
      int x;
      scanf("%d", &x), --x;
      pos[x] = -1;
    }
  }
  return 0;
}
