#include <bits/stdc++.h>
using namespace std;
int L, b, f;
bool isEmpty[200000];
int N;
int requestLen[1000];
int requestPut[1000];
int toLeft[200000];
int toRight[200000];
void fresh() {
  toLeft[0] = 0;
  if (isEmpty[0]) toLeft[0] = 1;
  for (int i = 1; i < L; ++i)
    if (isEmpty[i])
      toLeft[i] = toLeft[i - 1] + 1;
    else
      toLeft[i] = 0;
  int LL = L + 2000;
  toRight[LL - 1] = 0;
  if (isEmpty[LL - 1]) toRight[LL - 1] = 1;
  for (int i = LL - 2; i >= 0; --i)
    if (isEmpty[i])
      toRight[i] = toRight[i + 1] + 1;
    else
      toRight[i] = 0;
}
void init() {
  cin >> L >> b >> f;
  memset(isEmpty, true, sizeof(isEmpty));
}
int addCar(int carLen) {
  for (int i = 0; i < L; ++i) {
    if (toLeft[i] > b || i == 0) {
      if (toRight[i] >= f + carLen && i + carLen <= L) {
        for (int j = 0; j < carLen; ++j) isEmpty[i + j] = false;
        fresh();
        return i;
      }
    }
  }
  return -1;
}
void york() {
  cin >> N;
  fresh();
  for (int i = 1; i <= N; ++i) {
    int com;
    cin >> com >> requestLen[i];
    if (com == 1) {
      int posi = addCar(requestLen[i]);
      cout << posi << endl;
      requestPut[i] = posi;
    } else {
      int posi = requestPut[requestLen[i]];
      int carLen = requestLen[requestLen[i]];
      for (int j = 0; j < carLen; ++j) isEmpty[posi + j] = true;
      fresh();
    }
  }
}
int main() {
  init();
  york();
}
