#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 10;
const int inf = 522133279;
const int mod = 1000000007;
int L, b, f, n;
struct ccar {
  int pos;
  int len;
};
ccar car[110];
struct seg {
  int l;
  int r;
  int lsum;
  int rsum;
  int msum;
  int lazy;
} tree[3 * MAX];
void pushdown(int root) {
  if (tree[root].lazy != -1) {
    tree[(root << 1)].lazy = tree[(root << 1 | 1)].lazy = tree[root].lazy;
    tree[(root << 1)].lsum = tree[(root << 1)].rsum = tree[(root << 1)].msum =
        tree[root].lazy ? tree[(root << 1)].r - tree[(root << 1)].l + 1 : 0;
    tree[(root << 1 | 1)].lsum = tree[(root << 1 | 1)].rsum =
        tree[(root << 1 | 1)].msum =
            tree[root].lazy
                ? tree[(root << 1 | 1)].r - tree[(root << 1 | 1)].l + 1
                : 0;
    tree[root].lazy = -1;
  }
}
void pushup(int root) {
  tree[root].lsum = tree[(root << 1)].lsum;
  tree[root].rsum = tree[(root << 1 | 1)].rsum;
  if (tree[root].lsum == tree[(root << 1)].r - tree[(root << 1)].l + 1)
    tree[root].lsum += tree[(root << 1 | 1)].lsum;
  if (tree[root].rsum == tree[(root << 1 | 1)].r - tree[(root << 1 | 1)].l + 1)
    tree[root].rsum += tree[(root << 1)].rsum;
  tree[root].msum =
      max(tree[(root << 1)].rsum + tree[(root << 1 | 1)].lsum,
          max(tree[(root << 1)].msum, tree[(root << 1 | 1)].msum));
}
void build(int root, int l, int r) {
  tree[root].l = l;
  tree[root].r = r;
  tree[root].lazy = -1;
  tree[root].lsum = tree[root].rsum = tree[root].msum = r - l + 1;
  if (l == r) return;
  int mid(((l + r) >> 1));
  build((root << 1), l, mid);
  build((root << 1 | 1), mid + 1, r);
}
void modify(int root, int l, int r, int state) {
  if (tree[root].l >= l && tree[root].r <= r) {
    tree[root].lsum = tree[root].rsum = tree[root].msum =
        state ? tree[root].r - tree[root].l + 1 : 0;
    tree[root].lazy = state;
    return;
  }
  if (tree[root].l == tree[root].r) return;
  pushdown(root);
  int mid = ((tree[root].l + tree[root].r) >> 1);
  if (mid >= l) modify((root << 1), l, r, state);
  if (mid < r) modify((root << 1 | 1), l, r, state);
  pushup(root);
}
int query(int root, int v) {
  if (tree[root].msum < v) return -inf;
  if (tree[root].l == tree[root].r) return tree[root].l;
  pushdown(root);
  if (tree[root].lsum >= v) return tree[root].l;
  if (tree[(root << 1)].msum >= v) return query((root << 1), v);
  if (tree[(root << 1)].rsum + tree[(root << 1 | 1)].lsum >= v)
    return tree[(root << 1)].r - tree[(root << 1)].rsum + 1;
  return query((root << 1 | 1), v);
}
int main() {
  cin >> L >> b >> f;
  cin >> n;
  build(1, -b, L + f - 1);
  for (int i = 1; i <= n; i++) {
    int op, num;
    cin >> op >> num;
    if (op == 1) {
      int res = query(1, num + b + f) + b;
      if (res < -100000) res = -1;
      printf("%d\n", res);
      if (res != -1) {
        ccar tmp;
        tmp.len = num, tmp.pos = res;
        car[i] = tmp;
        modify(1, res, res + num - 1, 0);
      }
    } else
      modify(1, car[num].pos, car[num].pos + car[num].len - 1, 1);
  }
  return 0;
}
