#include <bits/stdc++.h>
using namespace std;
int L, b, f, n;
vector<int> carlen;
vector<int> carpos;
vector<int> zapr;
int carnum = 0;
struct cmp {
  bool operator()(const int &q, const int &w) { return carpos[q] < carpos[w]; }
};
set<int, cmp> otr;
int main() {
  cin >> L >> b >> f;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    zapr.push_back(-1);
    if (t == 1) {
      int len;
      cin >> len;
      carlen.push_back(len);
      carpos.push_back(-1);
      if (otr.empty()) {
        if (L >= len) {
          carpos[carnum] = 0;
          otr.insert(carnum);
        }
      } else {
        set<int, cmp>::iterator it;
        for (it = otr.begin(); it != otr.end(); it++) {
          set<int, cmp>::iterator next = it;
          next++;
          if (it == otr.begin()) {
            int seglen = carpos[*it];
            if ((len + f) <= seglen) {
              carpos[carnum] = 0;
              otr.insert(carnum);
              break;
            }
          }
          if (next == otr.end()) {
            int seglen = (L - 1) - (carpos[*it] + carlen[*it]) + 1;
            if ((len + b) <= seglen) {
              carpos[carnum] = carpos[*it] + carlen[*it] + b;
              otr.insert(carnum);
              break;
            }
          } else {
            int seglen = (carpos[*next] - 1) - (carpos[*it] + carlen[*it]) + 1;
            if ((len + b + f) <= seglen) {
              carpos[carnum] = carpos[*it] + carlen[*it] + b;
              otr.insert(carnum);
              break;
            }
          }
        }
      }
      cout << carpos[carnum] << endl;
      zapr[i] = carnum;
      carnum++;
    } else {
      int id;
      cin >> id;
      id--;
      otr.erase(zapr[id]);
    }
  }
}
