#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct SegmentTree {
  int l, r, lmax, rmax, Max, lazy;
} tree[N << 2];
int n, m, cnt, b, f, root = 1, Inl[N], Inr[N];
void Update(int z, int l, int r) {
  int mid = (l + r) >> 1;
  tree[z].Max =
      ((((tree[tree[z].l].Max > tree[tree[z].r].Max) ? (tree[tree[z].l].Max)
                                                     : (tree[tree[z].r].Max)) >
        tree[tree[z].l].rmax + tree[tree[z].r].lmax)
           ? (((tree[tree[z].l].Max > tree[tree[z].r].Max)
                   ? (tree[tree[z].l].Max)
                   : (tree[tree[z].r].Max)))
           : (tree[tree[z].l].rmax + tree[tree[z].r].lmax));
  if (tree[tree[z].l].lmax == mid - l + 1)
    tree[z].lmax = tree[tree[z].l].lmax + tree[tree[z].r].lmax;
  else
    tree[z].lmax = tree[tree[z].l].lmax;
  if (tree[tree[z].r].rmax == r - mid)
    tree[z].rmax = tree[tree[z].l].rmax + tree[tree[z].r].rmax;
  else
    tree[z].rmax = tree[tree[z].r].rmax;
}
void MakeTree(int l, int r) {
  int z = ++cnt;
  if (l == r) {
    tree[z].lmax = tree[z].rmax = tree[z].Max = 1;
    tree[z].lazy = -1;
    return;
  }
  int mid = (l + r) >> 1;
  tree[z].l = cnt + 1;
  MakeTree(l, mid);
  tree[z].r = cnt + 1;
  MakeTree(mid + 1, r);
  Update(z, l, r);
  tree[z].lazy = -1;
}
void Setlazy(int z, int l, int r, int val) {
  if (val == -1) return;
  tree[z].lmax = tree[z].rmax = tree[z].Max = (r - l + 1) * val;
  tree[z].lazy = val;
}
void Lazydown(int z, int l, int r) {
  int mid = (l + r) >> 1;
  Setlazy(tree[z].l, l, mid, tree[z].lazy);
  Setlazy(tree[z].r, mid + 1, r, tree[z].lazy);
  tree[z].lazy = -1;
}
void Add(int z, int l, int r, int ql, int qr, int val) {
  if (ql <= l && r <= qr) {
    Setlazy(z, l, r, val);
    return;
  }
  Lazydown(z, l, r);
  int mid = (l + r) >> 1;
  if (ql <= mid) Add(tree[z].l, l, mid, ql, qr, val);
  if (qr > mid) Add(tree[z].r, mid + 1, r, ql, qr, val);
  Update(z, l, r);
}
int Query(int z, int l, int r, int len) {
  if (tree[z].Max < len) return -1;
  Lazydown(z, l, r);
  int mid = (l + r) >> 1;
  if (tree[tree[z].l].Max >= len) return Query(tree[z].l, l, mid, len);
  if (tree[tree[z].l].rmax + tree[tree[z].r].lmax >= len)
    return mid - tree[tree[z].l].rmax + 1;
  if (tree[tree[z].r].Max >= len) return Query(tree[z].r, mid + 1, r, len);
  return -1;
}
void Solve() {
  int c, x;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &c, &x);
    if (c == 1) {
      if (tree[root].Max < b + f + x) {
        printf("-1\n");
        continue;
      }
      int set = Query(root, -b, n + f - 1, b + f + x);
      Add(root, -b, n + f - 1, set + b, set + b + x - 1, 0);
      Inl[i] = set + b;
      Inr[i] = set + b + x - 1;
      printf("%d\n", set + b);
    }
    if (c == 2) Add(root, -b, n + f - 1, Inl[x], Inr[x], 1);
  }
}
int main() {
  scanf("%d%d%d", &n, &b, &f);
  MakeTree(-b, n + f - 1);
  Solve();
  return 0;
}
