#include <bits/stdc++.h>
using namespace std;
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x < y ? x : y; }
struct node {
  int lmost, rmost;
  int maxlen;
  int flag;
} seg[105000 << 2];
struct Car {
  int l, r;
} car[105000];
int L, b, f;
int n;
void pushup(int l, int r, int index) {
  int m = (l + r) >> 1;
  seg[index].lmost = seg[index << 1].lmost;
  if (seg[index << 1].lmost == m - l + 1)
    seg[index].lmost += seg[index << 1 | 1].lmost;
  seg[index].rmost = seg[index << 1 | 1].rmost;
  if (seg[index << 1 | 1].rmost == r - m)
    seg[index].rmost += seg[index << 1].rmost;
  seg[index].maxlen = max(seg[index << 1].maxlen, seg[index << 1 | 1].maxlen);
  seg[index].maxlen =
      max(seg[index].maxlen, seg[index << 1].rmost + seg[index << 1 | 1].lmost);
}
void cover(int l, int r, int index) {
  seg[index].lmost = seg[index].rmost = seg[index].maxlen = 0;
  seg[index].flag = 1;
}
void recover(int l, int r, int index) {
  seg[index].lmost = seg[index].rmost = seg[index].maxlen = r - l + 1;
  seg[index].flag = 2;
}
void build(int l, int r, int index) {
  int m = (l + r) >> 1;
  if (l == r) {
    recover(l, r, index);
    return;
  }
  build(l, m, index << 1);
  build(m + 1, r, index << 1 | 1);
  pushup(l, r, index);
}
void pushdown(int l, int r, int index) {
  int m = (l + r) >> 1;
  if (seg[index].flag == 1) {
    cover(l, m, index << 1);
    cover(m + 1, r, index << 1 | 1);
    seg[index].flag = 0;
  } else if (seg[index].flag == 2) {
    recover(l, m, index << 1);
    recover(m + 1, r, index << 1 | 1);
    seg[index].flag = 0;
  }
}
int query(int len, int l, int r, int index) {
  int m = (l + r) >> 1;
  if (seg[index].lmost >= len)
    return l;
  else if (seg[index << 1].maxlen >= len) {
    pushdown(l, r, index);
    return query(len, l, m, index << 1);
  } else if (seg[index << 1].rmost + seg[index << 1 | 1].lmost >= len)
    return m - seg[index << 1].rmost + 1;
  else {
    pushdown(l, r, index);
    return query(len, m + 1, r, index << 1 | 1);
  }
}
void update(int L, int R, int l, int r, int index) {
  int m = (l + r) >> 1;
  if (L == l && R == r) {
    cover(l, r, index);
    return;
  }
  pushdown(l, r, index);
  if (R <= m)
    update(L, R, l, m, index << 1);
  else if (L > m)
    update(L, R, m + 1, r, index << 1 | 1);
  else {
    update(L, m, l, m, index << 1);
    update(m + 1, R, m + 1, r, index << 1 | 1);
  }
  pushup(l, r, index);
}
void leave(int L, int R, int l, int r, int index) {
  int m = (l + r) >> 1;
  if (L == l && R == r) {
    recover(l, r, index);
    return;
  }
  pushdown(l, r, index);
  if (R <= m)
    leave(L, R, l, m, index << 1);
  else if (L > m)
    leave(L, R, m + 1, r, index << 1 | 1);
  else {
    leave(L, m, l, m, index << 1);
    leave(m + 1, R, m + 1, r, index << 1 | 1);
  }
  pushup(l, r, index);
}
int main() {
  scanf("%d%d%d", &L, &b, &f);
  L += b + f - 1;
  build(0, L, 1);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int type, len;
    scanf("%d%d", &type, &len);
    if (type == 1) {
      int qlen = len + b + f;
      int ulen = len + b;
      if (seg[1].maxlen < qlen)
        printf("-1\n");
      else {
        int k;
        printf("%d\n", k = query(qlen, 0, L, 1));
        car[i].l = k + b;
        car[i].r = k + b + len - 1;
        update(car[i].l, car[i].r, 0, L, 1);
      }
    } else {
      leave(car[len].l, car[len].r, 0, L, 1);
    }
  }
  return 0;
}
