#include <bits/stdc++.h>
using namespace std;
struct rec {
  bool ex;
  int flag, max, lmax, rmax, l, r;
} tree[410000];
int n, m, b, f, i, x, y, l[110], ans[110], tot;
inline void read(int& x) {
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (int)ch - 48;
}
inline void pushdown(int p) {
  if (tree[p].flag != -1) {
    int u = tree[p].flag;
    tree[p].flag = -1;
    if (tree[(p << 1)].ex) {
      tree[(p << 1)].flag = tree[((p << 1) + 1)].flag = u;
    }
    tree[p].max = tree[p].lmax = tree[p].rmax = (tree[p].r - tree[p].l) * u;
  }
}
inline void updata(int p) {
  if (!tree[(p << 1)].ex) return;
  pushdown((p << 1));
  pushdown(((p << 1) + 1));
  tree[p].lmax = tree[(p << 1)].lmax;
  if (tree[p].lmax == tree[(p << 1)].r - tree[(p << 1)].l)
    tree[p].lmax += tree[((p << 1) + 1)].lmax;
  tree[p].rmax = tree[((p << 1) + 1)].rmax;
  if (tree[p].rmax == tree[((p << 1) + 1)].r - tree[((p << 1) + 1)].l)
    tree[p].rmax += tree[(p << 1)].rmax;
  tree[p].max = max(max(tree[(p << 1)].max, tree[((p << 1) + 1)].max),
                    tree[(p << 1)].rmax + tree[((p << 1) + 1)].lmax);
}
inline void build(int p, int l, int r) {
  if (r <= l) return;
  tree[p].l = l;
  tree[p].r = r;
  tree[p].ex = 1;
  tree[p].flag = -1;
  if (r == l + 1) {
    tree[p].max = tree[p].lmax = tree[p].rmax = 1;
    return;
  }
  build((p << 1), l, ((l + r) >> 1));
  build(((p << 1) + 1), ((l + r) >> 1), r);
  updata(p);
}
inline void cover(int p, int a, int b, int num) {
  int l = tree[p].l, r = tree[p].r;
  pushdown(p);
  if (l == a && r == b) {
    tree[p].flag = num;
    pushdown(p);
    return;
  }
  if (b <= ((l + r) >> 1))
    cover((p << 1), a, b, num);
  else if (a >= ((l + r) >> 1))
    cover(((p << 1) + 1), a, b, num);
  else {
    cover((p << 1), a, ((l + r) >> 1), num);
    cover(((p << 1) + 1), ((l + r) >> 1), b, num);
  }
  updata(p);
}
inline void find(int x) {
  int p = 1;
  while (1) {
    if (tree[p].r - tree[p].l == x) {
      ans[tot] = tree[p].l;
      break;
    }
    pushdown((p << 1));
    pushdown(((p << 1) + 1));
    if (tree[(p << 1)].max >= x)
      p = (p << 1);
    else if (tree[(p << 1)].rmax + tree[((p << 1) + 1)].lmax >= x) {
      ans[tot] = ((tree[(p << 1)].l + tree[((p << 1) + 1)].r) >> 1) -
                 tree[(p << 1)].rmax;
      break;
    } else
      p = ((p << 1) + 1);
  }
}
int main() {
  read(n);
  read(b), read(f);
  read(m);
  n = n + b + f;
  build(1, 1, n + 1);
  while (m--) {
    read(x);
    read(y);
    tot++;
    if (x == 1) {
      l[tot] = y;
      if (tree[1].max >= y + b + f) {
        find(y + b + f), printf("%d\n", ans[tot] - 1);
        cover(1, ans[tot] + b, ans[tot] + b + y, 0);
      } else
        printf("-1\n");
    } else
      cover(1, ans[y] + b, ans[y] + b + l[y], 1);
  }
  return 0;
}
