#include <bits/stdc++.h>
struct car {
  int pos;
  int len;
  car* next;
  car* prev;
};
int main(void) {
  int L, b, f;
  scanf("%d %d %d", &L, &b, &f);
  int n;
  scanf("%d", &n);
  car* list = new car();
  list->next = list->prev = NULL;
  list->pos = -b;
  list->len = 0;
  car* cars[100];
  for (int i = 0; i < n; ++i) {
    int type, num;
    scanf("%d %d", &type, &num);
    if (type == 1) {
      cars[i] = new car();
      cars[i]->len = num;
      car* p = list;
      while (1) {
        cars[i]->pos = p->pos + p->len + b;
        if (cars[i]->pos + cars[i]->len > L) {
          delete cars[i];
          cars[i] = NULL;
          puts("-1");
          break;
        }
        if (p->next == NULL ||
            cars[i]->pos + cars[i]->len + f <= p->next->pos) {
          cars[i]->prev = p;
          cars[i]->next = p->next;
          if (p->next != NULL) {
            p->next->prev = cars[i];
          }
          p->next = cars[i];
          printf("%d\n", cars[i]->pos);
          break;
        }
        p = p->next;
      }
    } else {
      cars[i] = NULL;
      cars[num - 1]->prev->next = cars[num - 1]->next;
      if (cars[num - 1]->next != NULL) {
        cars[num - 1]->next->prev = cars[num - 1]->prev;
      }
      delete cars[num - 1];
      cars[num - 1] = NULL;
    }
  }
  return 0;
}
