#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 205;
const int maxm = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int lsum[maxn << 2];
int rsum[maxn << 2];
int sum[maxn << 2];
int cov[maxn << 2];
vector<pair<int, int> > G;
int n, q, b, f;
void pushUp(int rt, int ln, int rn) {
  lsum[rt] = lsum[(rt << 1)], rsum[rt] = rsum[(rt << 1 | 1)];
  if (lsum[rt] == ln) lsum[rt] += lsum[(rt << 1 | 1)];
  if (rsum[rt] == rn) rsum[rt] += rsum[(rt << 1)];
  sum[rt] = max(sum[(rt << 1)], sum[(rt << 1 | 1)]);
  sum[rt] = max(sum[rt], rsum[(rt << 1)] + lsum[(rt << 1 | 1)]);
}
void build(int l, int r, int rt) {
  cov[rt] = -1;
  if (l == r) {
    lsum[rt] = rsum[rt] = sum[rt] = 1;
    return;
  }
  int mid = ((l + r) >> 1);
  build(l, mid, (rt << 1));
  build(mid + 1, r, (rt << 1 | 1));
  pushUp(rt, (mid - l + 1), (r - mid));
}
void pushDown(int rt, int ln, int rn) {
  if (cov[rt] != -1) {
    cov[(rt << 1)] = cov[(rt << 1 | 1)] = cov[rt];
    lsum[(rt << 1)] = rsum[(rt << 1)] = sum[(rt << 1)] = cov[rt] * ln;
    lsum[(rt << 1 | 1)] = rsum[(rt << 1 | 1)] = sum[(rt << 1 | 1)] =
        cov[rt] * rn;
    cov[rt] = -1;
  }
}
void update(int l, int r, int rt, int L, int R, int val) {
  if (l >= L && r <= R) {
    lsum[rt] = rsum[rt] = sum[rt] = val * (r - l + 1);
    cov[rt] = val;
    return;
  }
  int mid = ((l + r) >> 1);
  pushDown(rt, (mid - l + 1), (r - mid));
  if (L <= mid) update(l, mid, (rt << 1), L, R, val);
  if (R > mid) update(mid + 1, r, (rt << 1 | 1), L, R, val);
  pushUp(rt, (mid - l + 1), (r - mid));
}
int query(int l, int r, int rt, int val) {
  if (l == r) return l;
  int mid = ((l + r) >> 1);
  pushDown(rt, (mid - l + 1), (r - mid));
  if (sum[(rt << 1)] >= val) return query(l, mid, (rt << 1), val);
  if (rsum[(rt << 1)] + lsum[(rt << 1 | 1)] >= val)
    return mid - rsum[(rt << 1)] + 1;
  return query(mid + 1, r, (rt << 1 | 1), val);
}
int main() {
  while (scanf("%d%d%d", &n, &b, &f) != EOF) {
    n += b + f;
    build(1, n, 1);
    G.clear();
    scanf("%d", &q);
    while (q--) {
      int opt, val;
      scanf("%d%d", &opt, &val);
      if (opt == 1) {
        if (sum[1] < val + b + f)
          printf("-1\n"), G.push_back(pair<int, int>(0, 0));
        else {
          int pos = query(1, n, 1, val + b + f) + b;
          update(1, n, 1, pos, pos + val - 1, 0);
          printf("%d\n", pos - b - 1);
          G.push_back(pair<int, int>(pos, pos + val - 1));
        }
      } else
        update(1, n, 1, G[val - 1].first, G[val - 1].second, 1),
            G.push_back(pair<int, int>(0, 0));
    }
  }
  return 0;
}
