#include <bits/stdc++.h>
using namespace std;
const int maxn = 101002;
int lmax[maxn << 2], rmax[maxn << 2], mmax[maxn << 2], op, col[maxn << 2], n, m,
    f, b, st[102], ed[102];
void pushup(int rt, int l, int r) {
  int mid = (l + r) >> 1;
  lmax[rt] = lmax[rt << 1];
  rmax[rt] = rmax[rt << 1 | 1];
  mmax[rt] = max(mmax[rt << 1], mmax[rt << 1 | 1]);
  mmax[rt] = max(mmax[rt], rmax[rt << 1] + lmax[rt << 1 | 1]);
  if (lmax[rt << 1] == mid - l + 1) lmax[rt] += lmax[rt << 1 | 1];
  if (rmax[rt << 1 | 1] == r - mid) rmax[rt] += rmax[rt << 1];
}
void pushdown(int rt, int l, int r) {
  if (col[rt] != -1) {
    int mid = (l + r) >> 1;
    if (col[rt] == 1) {
      lmax[rt << 1] = rmax[rt << 1] = lmax[rt << 1 | 1] = rmax[rt << 1 | 1] =
          mmax[rt << 1] = mmax[rt << 1 | 1] = 0;
    } else {
      lmax[rt << 1] = rmax[rt << 1] = mmax[rt << 1] = mid - l + 1;
      lmax[rt << 1 | 1] = rmax[rt << 1 | 1] = mmax[rt << 1 | 1] = r - mid;
    }
    col[rt] = -1;
  }
}
void build(int rt, int l, int r) {
  lmax[rt] = rmax[rt] = mmax[rt] = r - l + 1;
  col[rt] = -1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  pushup(rt, l, r);
}
void updata(int rt, int l, int r, int L, int R, int val) {
  if (L <= l && r <= R) {
    col[rt] = val;
    lmax[rt] = rmax[rt] = mmax[rt] = (r - l + 1) * (val ^ 1);
    return;
  }
  pushdown(rt, l, r);
  int mid = (l + r) >> 1;
  if (mid >= L) updata(rt << 1, l, mid, L, R, val);
  if (mid < R) updata(rt << 1 | 1, mid + 1, r, L, R, val);
  pushup(rt, l, r);
}
int query(int rt, int l, int r, int len) {
  if (mmax[rt] < len) return -1;
  if (lmax[rt] >= len) return l;
  pushdown(rt, l, r);
  int mid = (l + r) >> 1;
  if (mmax[rt << 1] >= len) return query(rt << 1, l, mid, len);
  if (rmax[rt << 1] + lmax[rt << 1 | 1] >= len) return mid - rmax[rt << 1] + 1;
  return query(rt << 1 | 1, mid + 1, r, len);
}
int main() {
  int i, j, idx;
  while (scanf("%d%d%d", &n, &b, &f) != EOF) {
    n = n + b + f - 1;
    build(1, 0, n);
    scanf("%d", &m);
    for (i = 1; i <= m; i++) {
      scanf("%d%d", &op, &idx);
      if (op == 1) {
        int len = idx + b + f;
        int k = query(1, 0, n, len);
        printf("%d\n", k);
        if (k != -1) {
          st[i] = k + b;
          ed[i] = k + b + idx - 1;
          updata(1, 0, n, st[i], ed[i], 1);
        }
      } else {
        updata(1, 0, n, st[idx], ed[idx], 0);
      }
    }
  }
  return 0;
}
