#include <bits/stdc++.h>
using namespace std;
int L, B, F;
int N;
bool occupy[200000];
int l[200], r[200], n;
int main() {
  scanf("%d %d %d", &L, &B, &F);
  scanf("%d", &N);
  for (int Ni = 0; Ni < N; Ni++) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int lth;
      scanf("%d", &lth);
      int p = B + F + lth;
      int cnt = 0;
      int Li;
      if (lth == L) {
        for (Li = 0; Li < L; Li++)
          if (occupy[Li]) {
            puts("-1");
            goto ED;
          }
        for (Li = 0; Li < L; Li++) occupy[Li] = true;
        l[Ni] = 0;
        r[Ni] = L - 1;
        n++;
        puts("0");
      ED:;
        continue;
      }
      if (L - 1 < lth + F - 1) goto nxt;
      for (Li = 0; Li <= lth + F - 1; Li++) {
        if (occupy[Li]) goto nxt;
      }
      for (Li = 0; Li <= lth - 1; Li++) occupy[Li] = true;
      l[Ni] = 0;
      r[Ni] = lth - 1;
      n++;
      puts("0");
      continue;
    nxt:;
      for (Li = 0; Li < L; Li++) {
        if (occupy[Li])
          cnt = 0;
        else
          cnt++;
        if (cnt == p) break;
      }
      if (Li == L) {
        if (L - B - lth < 0) {
          puts("-1");
          continue;
        }
        cnt = 0;
        int st;
        st = max(L - p + 1, 0);
        for (Li = max(L - p + 1, 0); Li <= L - 1; Li++) {
          if (occupy[Li]) {
            st = Li + 1;
            cnt = 0;
          } else
            cnt++;
        }
        if (cnt < B + lth) {
          puts("-1");
          continue;
        }
        printf("%d\n", st + B);
        for (int i = st + B; i <= st + B + lth - 1; i++) occupy[i] = true;
        l[Ni] = st + B;
        r[Ni] = st + B + lth - 1;
      } else {
        printf("%d\n", Li - F - lth + 1);
        for (int i = Li - F - lth + 1; i <= Li - F; i++) occupy[i] = true;
        l[Ni] = Li - F - lth + 1;
        r[Ni] = Li - F;
        n++;
      }
    } else {
      int p;
      scanf("%d", &p);
      for (int i = l[p - 1]; i <= r[p - 1]; i++) occupy[i] = false;
    }
  }
}
