#include <bits/stdc++.h>
using namespace std;
int sum[110000 << 2];
int lsum[110000 << 2];
int rsum[110000 << 2];
int col[110000 << 2];
void PushUp(int o, int len) {
  sum[o] = max(sum[2 * o], sum[2 * o + 1]);
  sum[o] = max(sum[o], rsum[2 * o] + lsum[2 * o + 1]);
  lsum[o] = lsum[2 * o];
  if (lsum[2 * o] == len - (len >> 1)) lsum[o] += lsum[2 * o + 1];
  rsum[o] = rsum[2 * o + 1];
  if (rsum[2 * o + 1] == len >> 1) rsum[o] += rsum[2 * o];
  return;
}
void PushDown(int o, int len) {
  if (col[o] == -1) return;
  col[2 * o] = col[2 * o + 1] = col[o];
  sum[2 * o] = lsum[2 * o] = rsum[2 * o] = (len - (len >> 1)) * col[o];
  sum[2 * o + 1] = rsum[2 * o + 1] = lsum[2 * o + 1] = (len >> 1) * col[o];
  col[o] = -1;
  return;
}
void Updata(int l, int r, int o, int L, int R, int x) {
  if (L <= l && r <= R) {
    col[o] = x;
    sum[o] = lsum[o] = rsum[o] = (r - l + 1) * x;
    return;
  }
  PushDown(o, r - l + 1);
  int m = (r + l) >> 1;
  if (L <= m) Updata(l, m, 2 * o, L, R, x);
  if (m + 1 <= R) Updata(m + 1, r, 2 * o + 1, L, R, x);
  PushUp(o, r - l + 1);
  return;
}
int Query(int l, int r, int o, int D) {
  if (l == r) return l;
  PushDown(o, r - l + 1);
  int m = (l + r) >> 1;
  if (sum[2 * o] >= D)
    return Query(l, m, 2 * o, D);
  else {
    if (rsum[2 * o] + lsum[2 * o + 1] >= D) {
      return m - rsum[2 * o] + 1;
    }
    return Query(m + 1, r, 2 * o + 1, D);
  }
}
void BuiltTree(int l, int r, int o) {
  col[o] = -1;
  if (l == r) {
    sum[o] = lsum[o] = rsum[o] = 1;
    return;
  }
  int m = (l + r) >> 1;
  BuiltTree(l, m, 2 * o);
  BuiltTree(m + 1, r, 2 * o + 1);
  PushUp(o, r - l + 1);
  return;
}
int L, b, f;
int px[110];
int py[110];
int main() {
  while (~scanf("%d%d%d", &L, &b, &f)) {
    int n;
    scanf("%d", &n);
    BuiltTree(1, L + b + f, 1);
    for (int i = 0; i < n; i++) {
      int q, a;
      scanf("%d%d", &q, &a);
      if (q == 1) {
        if (sum[1] < a + b + f) {
          puts("-1");
          continue;
        }
        int p = Query(1, L + b + f, 1, a + b + f);
        p = p + b;
        printf("%d\n", p - b - 1);
        px[i] = p;
        py[i] = p + a - 1;
        Updata(1, L + b + f, 1, px[i], py[i], 0);
      }
      if (q == 2) {
        Updata(1, L + b + f, 1, px[a - 1], py[a - 1], 1);
      }
    }
  }
  return 0;
}
