#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxm = 105;
int lsum[maxn << 2], rsum[maxn << 2];
int setv[maxn << 2], msum[maxn << 2];
int lq[maxm], rq[maxm];
int n, q, b, f;
void push_up(int l, int r, int rt) {
  lsum[rt] = lsum[rt << 1];
  rsum[rt] = rsum[rt << 1 | 1];
  int m = (l + r) >> 1;
  if (lsum[rt] == m - l + 1) lsum[rt] += lsum[rt << 1 | 1];
  if (rsum[rt] == r - m) rsum[rt] += rsum[rt << 1];
  msum[rt] = max(max(msum[rt << 1], msum[rt << 1 | 1]),
                 lsum[rt << 1 | 1] + rsum[rt << 1]);
}
void build(int l, int r, int rt) {
  lsum[rt] = rsum[rt] = msum[rt] = r - l + 1;
  setv[rt] = -1;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  push_up(l, r, rt);
}
void push_down(int l, int r, int rt) {
  if (setv[rt] != -1) {
    setv[rt << 1] = setv[rt << 1 | 1] = setv[rt];
    int m = (l + r) >> 1;
    lsum[rt << 1] = rsum[rt << 1] = msum[rt << 1] = setv[rt] ? m - l + 1 : 0;
    lsum[rt << 1 | 1] = rsum[rt << 1 | 1] = msum[rt << 1 | 1] =
        setv[rt] ? r - m : 0;
    setv[rt] = -1;
  }
}
void update(int cl, int cr, int val, int l, int r, int rt) {
  if (cl <= l && r <= cr) {
    lsum[rt] = rsum[rt] = msum[rt] = val ? r - l + 1 : 0;
    setv[rt] = val;
    return;
  }
  push_down(l, r, rt);
  int m = (l + r) >> 1;
  if (cl <= m) update(cl, cr, val, l, m, rt << 1);
  if (cr > m) update(cl, cr, val, m + 1, r, rt << 1 | 1);
  push_up(l, r, rt);
}
int queries(int val, 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] >= val) return queries(val, l, m, rt << 1);
  if (rsum[rt << 1] + lsum[rt << 1 | 1] >= val) return m - rsum[rt << 1] + 1;
  return queries(val, m + 1, r, rt << 1 | 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> b >> f >> q;
  build(1, n + b + f, 1);
  int op, a;
  for (int i = 1; i <= q; ++i) {
    cin >> op >> a;
    if (op == 1) {
      if (msum[1] < a + b + f)
        cout << -1 << endl;
      else {
        int t = queries(a + b + f, 1, n + b + f, 1);
        lq[i] = t, rq[i] = a;
        update(b + t, b + t + a - 1, 0, 1, n + b + f, 1);
        cout << t - 1 << endl;
      }
    } else
      update(b + lq[a], b + lq[a] + rq[a] - 1, 1, 1, n + b + f, 1);
  }
  return 0;
}
