#include <bits/stdc++.h>
using namespace std;
struct segment_t {
  segment_t(int begin_, int length_, bool used_)
      : begin(begin_), length(length_), used(used_) {}
  int begin, length;
  bool used;
};
list<segment_t> lot;
map<int, list<segment_t>::iterator> cars;
list<segment_t>::iterator lot_prev(list<segment_t>::iterator it) {
  return it == lot.begin() ? it : --it;
}
list<segment_t>::iterator lot_next(list<segment_t>::iterator it) {
  return it == lot.end() ? it : ++it;
}
bool lot_isFirst(list<segment_t>::iterator it) { return it == lot.begin(); }
bool lot_isLast(list<segment_t>::iterator it) {
  return lot_next(it) == lot.end();
}
bool CarFits(list<segment_t>::iterator it, int length, int back, int front) {
  if (!lot_isFirst(it)) length += back;
  if (!lot_isLast(it)) length += front;
  return it->length >= length;
}
int ParkCar(int id, int length, int back, int front) {
  for (list<segment_t>::iterator it = lot.begin(); it != lot.end(); ++it)
    if (!it->used && CarFits(it, length, back, front)) {
      const int offset = lot_isFirst(it) ? 0 : back;
      if (offset > 0) {
        const segment_t spaceBehind(it->begin, offset, false);
        lot.insert(it, spaceBehind);
        it->begin += offset, it->length -= offset;
      }
      const int ahead = it->length - length;
      if (ahead > 0) {
        const segment_t spaceAhead(it->begin + length, ahead, false);
        lot.insert(lot_next(it), spaceAhead);
        it->length -= ahead;
      }
      cars[id] = it;
      it->used = true;
      return it->begin;
    }
  return -1;
}
void LeaveParkingLot(list<segment_t>::iterator it) {
  it->used = false;
  if (!lot_isFirst(it) && !lot_prev(it)->used) {
    const list<segment_t>::iterator pit = lot_prev(it);
    it->begin = pit->begin, it->length += pit->length;
    lot.erase(pit);
  }
  if (!lot_isLast(it) && !lot_next(it)->used) {
    const list<segment_t>::iterator nit = lot_next(it);
    it->length += nit->length;
    lot.erase(nit);
  }
}
int main() {
  int L, back, front;
  scanf("%d %d %d", &L, &back, &front);
  int n;
  scanf("%d", &n);
  lot.push_back(segment_t(0, L, false));
  for (int i = 0; i < n; ++i) {
    int type, x;
    scanf("%d %d", &type, &x);
    if (type == 1) {
      const int start = ParkCar(i, x, back, front);
      printf("%d\n", start);
    } else {
      LeaveParkingLot(cars[x - 1]);
    }
  }
  return 0;
}
