#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 300;
int lsum[N << 2], msum[N << 2], rsum[N << 2];
int lazy[N << 2];
struct node {
  int l, r;
} a[105];
void push_up(int l, int r, int rt) {
  int len = r - l + 1;
  int lenr = len >> 1;
  int lenl = len - lenr;
  lsum[rt] = lsum[rt << 1];
  rsum[rt] = rsum[rt << 1 | 1];
  msum[rt] = max(msum[rt << 1], msum[rt << 1 | 1]);
  if (lsum[rt] == lenl) lsum[rt] += lsum[rt << 1 | 1];
  if (rsum[rt] == lenr) rsum[rt] += rsum[rt << 1];
  msum[rt] = max(msum[rt], lsum[rt << 1 | 1] + rsum[rt << 1]);
}
void push_down(int l, int r, int rt) {
  if (lazy[rt] != -1) {
    int len = r - l + 1;
    int lenr = len >> 1;
    int lenl = len - lenr;
    lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];
    lsum[rt << 1] = rsum[rt << 1] = msum[rt << 1] = lenl * lazy[rt];
    lsum[rt << 1 | 1] = rsum[rt << 1 | 1] = msum[rt << 1 | 1] = lenr * lazy[rt];
    lazy[rt] = -1;
  }
}
void build(int l, int r, int rt) {
  lsum[rt] = msum[rt] = rsum[rt] = 0;
  lazy[rt] = -1;
  if (l == r) {
    lsum[rt] = msum[rt] = rsum[rt] = 1;
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  push_up(l, r, rt);
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    lsum[rt] = msum[rt] = rsum[rt] = val * (r - l + 1);
    lazy[rt] = val;
    return;
  }
  push_down(l, r, rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, val, l, m, rt << 1);
  if (m < R) update(L, R, val, m + 1, r, rt << 1 | 1);
  push_up(l, r, rt);
}
int query(int len, int l, int r, int rt) {
  if (l == r) return l;
  push_down(l, r, rt);
  int m = (l + r) >> 1;
  if (msum[rt << 1] >= len)
    return query(len, l, m, rt << 1);
  else if (lsum[rt << 1 | 1] + rsum[rt << 1] >= len)
    return m - rsum[rt << 1] + 1;
  else
    return query(len, m + 1, r, rt << 1 | 1);
}
int main() {
  int n, b, f;
  scanf("%d %d %d", &n, &b, &f);
  n += b + f;
  int q;
  scanf("%d", &q);
  build(1, n, 1);
  for (int i = 1; i <= q; ++i) {
    int op, len;
    scanf("%d %d", &op, &len);
    if (op == 1) {
      len += b + f;
      if (msum[1] >= len) {
        int pos = query(len, 1, n, 1);
        a[i].l = pos + b;
        a[i].r = pos + len - 1 - f;
        update(a[i].l, a[i].r, 0, 1, n, 1);
        --pos;
        printf("%d\n", pos);
      } else
        printf("-1\n");
    } else {
      update(a[len].l, a[len].r, 1, 1, n, 1);
    }
  }
  return 0;
}
