#include <bits/stdc++.h>
using namespace std;
const int MAXN = 102005;
struct node {
  int lsum, rsum, _max, lazy;
} tree[MAXN * 4 + 10];
struct info {
  int L, R, used;
} all[MAXN];
int n, b, f, m;
void setlazy(int root, int L, int R, int type) {
  tree[root] = (node){type * (R - L + 1), type * (R - L + 1),
                      type * (R - L + 1), type + 1};
}
void lazydown(int root, int L, int R) {
  if (!tree[root].lazy) return;
  int M = (L + R) >> 1;
  setlazy(root << 1, L, M, tree[root].lazy - 1);
  setlazy(root << 1 | 1, M + 1, R, tree[root].lazy - 1);
  tree[root].lazy = 0;
}
void pushup(int root, int L, int R) {
  int M = (L + R) >> 1;
  if (tree[root << 1].lsum == M - L + 1)
    tree[root].lsum = tree[root << 1].lsum + tree[root << 1 | 1].lsum;
  else
    tree[root].lsum = tree[root << 1].lsum;
  if (tree[root << 1 | 1].rsum == R - M)
    tree[root].rsum = tree[root << 1 | 1].rsum + tree[root << 1].rsum;
  else
    tree[root].rsum = tree[root << 1 | 1].rsum;
  tree[root]._max = max(tree[root << 1]._max,
                        max(tree[root << 1 | 1]._max,
                            tree[root << 1].rsum + tree[root << 1 | 1].lsum));
}
void modify(int root, int L, int R, int l, int r, int type) {
  if (L == l && R == r) {
    setlazy(root, L, R, type);
    return;
  }
  int M = (L + R) >> 1;
  lazydown(root, L, R);
  if (r <= M)
    modify(root << 1, L, M, l, r, type);
  else if (l > M)
    modify(root << 1 | 1, M + 1, R, l, r, type);
  else
    modify(root << 1, L, M, l, M, type),
        modify(root << 1 | 1, M + 1, R, M + 1, r, type);
  pushup(root, L, R);
}
int query(int root, int L, int R, int len) {
  if (tree[root]._max < len) return -1;
  if (R - L + 1 == len) return L;
  int M = (L + R) >> 1;
  lazydown(root, L, R);
  if (tree[root << 1]._max >= len)
    return query(root << 1, L, M, len);
  else if (tree[root << 1].rsum + tree[root << 1 | 1].lsum >= len)
    return M - tree[root << 1].rsum + 1;
  else
    return query(root << 1 | 1, M + 1, R, len);
}
void build(int root, int L, int R) {
  if (L == R) {
    tree[root] = (node){1, 1, 1, 0};
    return;
  }
  int M = (L + R) >> 1;
  build(root << 1, L, M);
  build(root << 1 | 1, M + 1, R);
  pushup(root, L, R);
}
int ans[MAXN];
int _ans[MAXN];
void _q(int root, int L, int R) {
  if (L == R) {
    ans[L] = tree[root]._max;
    return;
  }
  int M = (L + R) >> 1;
  lazydown(root, L, R);
  _q(root << 1, L, M);
  _q(root << 1 | 1, M + 1, R);
}
void moni(int L, int R, int type) {
  for (int i = L; i <= R; i++) _ans[i] = type;
}
bool cmp() {
  for (int i = 1; i <= n; i++)
    if (ans[i] != _ans[i]) return false;
  return true;
}
int main() {
  scanf("%d%d%d", &n, &b, &f);
  n += b + f - 1;
  build(1, 0, n);
  scanf("%d", &m);
  int xnt = 0;
  for (int i = 1; i <= m; i++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      xnt++;
      int Len;
      scanf("%d", &Len);
      int L = query(1, 0, n, Len + b + f);
      printf("%d\n", L);
      if (L >= 0) {
        all[i] = (info){L + b, L + b + Len - 1, 1};
        modify(1, 0, n, L + b, L + b + Len - 1, 0);
      }
    } else {
      int pos;
      scanf("%d", &pos);
      if (all[pos].used) {
        all[pos].used = 0;
        modify(1, 0, n, all[pos].L, all[pos].R, 1);
      }
    }
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
