#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct node {
  int ls, rs, ms;
  int flag;
} tree[maxn << 2];
int st[maxn], ed[maxn];
void pushUp(int root, int len) {
  tree[root].ls = tree[root << 1].ls;
  tree[root].rs = tree[root << 1 | 1].rs;
  if (tree[root].ls == len - (len >> 1))
    tree[root].ls += tree[root << 1 | 1].ls;
  if (tree[root].rs == (len >> 1)) tree[root].rs += tree[root << 1].rs;
  tree[root].ms = max(tree[root << 1 | 1].ls + tree[root << 1].rs,
                      max(tree[root << 1].ms, tree[root << 1 | 1].ms));
}
void pushdown(int root, int len) {
  if (tree[root].flag != -1) {
    tree[root << 1].flag = tree[root << 1 | 1].flag = tree[root].flag;
    tree[root << 1].ms = tree[root << 1].ls = tree[root << 1].rs =
        tree[root].flag ? len - (len >> 1) : 0;
    tree[root << 1 | 1].ms = tree[root << 1 | 1].ls = tree[root << 1 | 1].rs =
        tree[root].flag ? (len >> 1) : 0;
    tree[root].flag = -1;
  }
}
void build(int root, int L, int R) {
  tree[root].ms = tree[root].ls = tree[root].rs = R - L + 1;
  tree[root].flag = -1;
  if (L == R) return;
  int mid = (L + R) >> 1;
  build(root << 1, L, mid);
  build(root << 1 | 1, mid + 1, R);
}
void update(int L, int R, int c, int l, int r, int root) {
  if (L <= l && r <= R) {
    tree[root].ms = tree[root].ls = tree[root].rs = c ? r - l + 1 : 0;
    tree[root].flag = c;
    return;
  }
  pushdown(root, r - l + 1);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, c, l, mid, root << 1);
  if (mid < R) update(L, R, c, mid + 1, r, root << 1 | 1);
  pushUp(root, r - l + 1);
}
int query(int w, int l, int r, int root) {
  if (l == r) return l;
  pushdown(root, r - l + 1);
  int mid = (l + r) >> 1;
  if (tree[root << 1].ms >= w)
    return query(w, l, mid, root << 1);
  else if (tree[root << 1].rs + tree[root << 1 | 1].ls >= w)
    return mid - tree[root << 1].rs + 1;
  return query(w, mid + 1, r, root << 1 | 1);
}
int main() {
  int n, l, b, f;
  while (~scanf("%d%d%d", &l, &b, &f)) {
    scanf("%d", &n);
    int sum = l + b + f;
    build(1, 1, sum);
    for (int i = 1; i <= n; i++) {
      int op, a;
      scanf("%d%d", &op, &a);
      if (op == 1) {
        if (tree[1].ms < a + b + f) {
          printf("-1\n");
          continue;
        }
        int pos = query(a + b + f, 1, sum, 1);
        st[i] = pos, ed[i] = a;
        update(b + pos, b + pos + a - 1, 0, 1, sum, 1);
        printf("%d\n", pos - 1);
      } else
        update(b + st[a], b + st[a] + ed[a] - 1, 1, 1, sum, 1);
    }
  }
  return 0;
}
