#include <bits/stdc++.h>
using namespace std;
int carPos[100];
int carLen[100];
int id[100];
int cCars;
int main() {
  int L, B, F, N;
  cin >> L >> B >> F >> N;
  cCars = 0;
  int curId = 1;
  for (int i = 0; i < N; i++) {
    int tp;
    cin >> tp;
    if (tp == 1) {
      int ln;
      cin >> ln;
      int bestLoc = (1 << 30);
      int loc = 0;
      if ((loc + ln) > L) loc = (1 << 30);
      for (int c = 0; c < cCars; c++)
        if ((carPos[c] < loc + ln + F) && ((carPos[c] + carLen[c]) > loc - B))
          loc = (1 << 30);
      bestLoc = min(bestLoc, loc);
      for (int k = 0; k < cCars; k++) {
        loc = carPos[k] + carLen[k] + B;
        if ((loc + ln) > L) loc = (1 << 30);
        for (int c = 0; c < cCars; c++)
          if ((carPos[c] < loc + ln + F) && ((carPos[c] + carLen[c]) > loc - B))
            loc = (1 << 30);
        bestLoc = min(bestLoc, loc);
      }
      if (bestLoc == (1 << 30))
        cout << -1 << endl;
      else {
        cout << bestLoc << endl;
        carPos[cCars] = bestLoc;
        carLen[cCars] = ln;
        id[cCars] = curId;
        cCars++;
      }
    } else {
      int d;
      cin >> d;
      int c;
      for (c = 0; c < cCars; c++)
        if (d == id[c]) break;
      for (; c < (cCars - 1); c++) {
        carPos[c] = carPos[c + 1];
        carLen[c] = carLen[c + 1];
        id[c] = id[c + 1];
      }
      cCars--;
    }
    curId++;
  }
  return 0;
}
