#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
struct Seg {
  int lsum[maxn << 2], rsum[maxn << 2], msum[maxn << 2];
  int cover[maxn << 2];
  void Pushdown(int rt, int m) {
    if (cover[rt] != -1) {
      cover[rt << 1] = cover[rt << 1 | 1] = cover[rt];
      lsum[rt << 1] = rsum[rt << 1] = msum[rt << 1] =
          cover[rt] ? 0 : m - (m >> 1);
      lsum[rt << 1 | 1] = rsum[rt << 1 | 1] = msum[rt << 1 | 1] =
          cover[rt] ? 0 : (m >> 1);
      cover[rt] = -1;
    }
  }
  void Pushup(int rt, int m) {
    lsum[rt] = lsum[rt << 1];
    rsum[rt] = rsum[rt << 1 | 1];
    if (lsum[rt] == m - (m >> 1)) lsum[rt] += lsum[rt << 1 | 1];
    if (rsum[rt] == (m >> 1)) rsum[rt] += rsum[rt << 1];
    msum[rt] = max(msum[rt << 1], msum[rt << 1 | 1]);
    msum[rt] = max(msum[rt], rsum[rt << 1] + lsum[rt << 1 | 1]);
  }
  void update(int L, int R, int c, int l, int r, int rt) {
    if (L <= l && r <= R) {
      cover[rt] = c;
      lsum[rt] = rsum[rt] = msum[rt] = c ? 0 : r - l + 1;
      return;
    }
    Pushdown(rt, r - l + 1);
    int m = l + r >> 1;
    if (L <= m) update(L, R, c, l, m, rt << 1);
    if (R > m) update(L, R, c, m + 1, r, rt << 1 | 1);
    Pushup(rt, r - l + 1);
  }
  int query(int d, int l, int r, int rt) {
    if (msum[rt] < d) return -1;
    if (l == r) return l;
    Pushdown(rt, r - l + 1);
    int m = l + r >> 1;
    if (msum[rt << 1] >= d) return query(d, l, m, rt << 1);
    if (rsum[rt << 1] + lsum[rt << 1 | 1] >= d) return m - rsum[rt << 1] + 1;
    return query(d, m + 1, r, rt << 1 | 1);
  }
} seg;
int main() {
  int s[101], r[101];
  int n, f, b, m, op, a;
  scanf("%d%d%d", &n, &b, &f);
  n = n + f + b - 1;
  seg.update(0, n, 0, 0, n, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &op, &a);
    if (op == 1) {
      int len = a + b + f;
      int p = seg.query(len, 0, n, 1);
      if (p == -1)
        printf("-1\n");
      else {
        printf("%d\n", p);
        s[i] = p + b;
        r[i] = s[i] + a - 1;
        seg.update(s[i], r[i], 1, 0, n, 1);
      }
    } else {
      seg.update(s[a], r[a], 0, 0, n, 1);
    }
  }
  return 0;
}
