#include <bits/stdc++.h>
using std::list;
const int N = 128;
struct car {
  int coord, length, req;
};
list<car> cars;
int InsertCar(int length, int req, int b, int f) {
  list<car>::iterator i = cars.begin(), j = ++cars.begin();
  int from, to;
  while (j != cars.end()) {
    from = i->coord + i->length + b;
    to = j->coord - f;
    if (to - from >= length) {
      cars.insert(j, (car){from, length, req});
      return from;
    }
    ++i, ++j;
  }
  return -1;
}
void DeleteCar(int req) {
  list<car>::iterator i = cars.begin();
  while (i != cars.end()) {
    if (i->req == req) {
      cars.erase(i);
      break;
    }
    ++i;
  }
}
int main() {
  int l, b, f, n;
  scanf("%d%d%d%d", &l, &b, &f, &n);
  cars.push_back((car){-b, 0, -1});
  cars.push_back((car){l + f, 0, -1});
  int type, req;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &type, &req);
    if (type == 1)
      printf("%d\n", InsertCar(req, i, b, f));
    else
      DeleteCar(req - 1);
  }
  return 0;
}
