#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150000;
struct node {
  int left, right, mk;
  int msum, lsum, rsum;
  int mid() { return (left + right) >> 1; }
  int len() { return right - left + 1; }
} tr[MAXN * 4];
int pos[105], len[105];
void push_down(int k) {
  if (tr[k].mk != -1) {
    tr[(k << 1)].msum = tr[(k << 1)].lsum = tr[(k << 1)].rsum =
        tr[k].mk ? 0 : tr[(k << 1)].len();
    tr[((k << 1) | 1)].msum = tr[((k << 1) | 1)].lsum =
        tr[((k << 1) | 1)].rsum = tr[k].mk ? 0 : tr[((k << 1) | 1)].len();
    tr[(k << 1)].mk = tr[((k << 1) | 1)].mk = tr[k].mk;
    tr[k].mk = -1;
  }
}
void push_up(int k) {
  tr[k].lsum = tr[(k << 1)].lsum;
  tr[k].rsum = tr[((k << 1) | 1)].rsum;
  if (tr[k].lsum == tr[(k << 1)].len()) tr[k].lsum += tr[((k << 1) | 1)].lsum;
  if (tr[k].rsum == tr[((k << 1) | 1)].len()) tr[k].rsum += tr[(k << 1)].rsum;
  tr[k].msum = max(tr[(k << 1)].rsum + tr[((k << 1) | 1)].lsum,
                   max(tr[(k << 1)].msum, tr[((k << 1) | 1)].msum));
}
void build(int l, int r, int k) {
  tr[k].left = l;
  tr[k].right = r;
  tr[k].msum = tr[k].lsum = tr[k].rsum = tr[k].len();
  tr[k].mk = -1;
  if (l == r) return;
  int mid = tr[k].mid();
  build(l, mid, (k << 1));
  build(mid + 1, r, ((k << 1) | 1));
}
void update(int l, int r, int val, int k) {
  if (l <= tr[k].left && r >= tr[k].right) {
    tr[k].msum = tr[k].lsum = tr[k].rsum = val ? 0 : tr[k].len();
    tr[k].mk = val;
    return;
  }
  push_down(k);
  int mid = tr[k].mid();
  if (l <= mid) update(l, r, val, (k << 1));
  if (r > mid) update(l, r, val, ((k << 1) | 1));
  push_up(k);
}
int query(int d, int k) {
  if (tr[k].left == tr[k].right) return tr[k].left;
  push_down(k);
  int mid = tr[k].mid();
  if (d <= tr[(k << 1)].msum)
    return query(d, (k << 1));
  else if (d <= tr[(k << 1)].rsum + tr[((k << 1) | 1)].lsum)
    return mid - tr[(k << 1)].rsum + 1;
  else
    return query(d, ((k << 1) | 1));
}
int main() {
  int L, b, f, n, op;
  scanf("%d%d%d%d", &L, &b, &f, &n);
  build(1, b + L + f, 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &op, &len[i]);
    if (op == 1) {
      if (tr[1].msum < b + len[i] + f)
        printf("-1\n");
      else {
        pos[i] = query(b + len[i] + f, 1) + b;
        printf("%d\n", pos[i] - 1 - b);
        update(pos[i], pos[i] + len[i] - 1, 1, 1);
      }
    } else {
      int mk = len[i];
      update(pos[mk], pos[mk] + len[mk] - 1, 0, 1);
    }
  }
  return 0;
}
