#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int L, B, F;
int n;
struct Car {
  int a;
  int b;
  int id;
  Car() {}
  Car(int a, int b, int id = -1) : a(a), b(b), id(id) {}
  friend bool operator<(const Car& a, const Car& b) { return a.a < b.a; }
};
set<Car> queries;
int main() {
  scanf("%d%d%d", &L, &B, &F);
  scanf("%d", &n);
  queries.insert(Car(-1 - B, -B));
  queries.insert(Car(L + F, L + F + 1));
  for (int i = 0; i < (int)(n); ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int len;
      scanf("%d", &len);
      Car c;
      bool ok = 0;
      for (set<Car>::iterator a = queries.begin(); a != queries.end(); ++a) {
        set<Car>::iterator b = a;
        ++b;
        if (b == queries.end()) break;
        if (b->a - F - a->b - B >= len) {
          c.a = a->b + B;
          c.b = c.a + len;
          c.id = i + 1;
          queries.insert(c);
          ok = 1;
          printf("%d\n", c.a);
          break;
        }
      }
      if (!ok) printf("-1\n");
    } else {
      int id;
      scanf("%d", &id);
      for (set<Car>::iterator a = queries.begin(); a != queries.end(); ++a)
        if (a->id == id) {
          queries.erase(a);
          break;
        }
    }
  }
  return 0;
}
