#include <bits/stdc++.h>
using namespace std;
int L, B, F, LL[1002];
int tree[2000002], add[2000002], arr[200002];
int query(int ind, int s, int e, int S, int E) {
  if (s > e || e < S || s > E) return 0;
  if (add[ind]) {
    return add[ind];
  }
  if (s >= S && e <= E) {
    return tree[ind];
  }
  return max(query(ind * 2, s, (s + e) / 2, S, E),
             query(ind * 2 + 1, (s + e) / 2 + 1, e, S, E));
}
void update(int ind, int s, int e, int S, int E, int val) {
  if (s > e || e < S || s > E) return;
  if (s >= S && e <= E) {
    tree[ind] = val;
    add[ind] = val;
    return;
  }
  update(ind * 2, s, (s + e) / 2, S, E, val);
  update(ind * 2 + 1, (s + e) / 2 + 1, e, S, E, val);
  tree[ind] = max(tree[ind * 2], tree[ind * 2 + 1]);
}
int main() {
  int M = 0, N;
  scanf("%d %d %d", &L, &B, &F);
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int I, ind;
    scanf("%d %d", &I, &ind);
    M++;
    if (I == 1) {
      LL[M] = ind;
      int last = -B - 5, FF = 0;
      for (int j = 0; j + ind - 1 < L; j++) {
        if (!arr[j] && j - last - 1 >= B &&
            !query(1, 0, L + 101, j, j + ind + F - 1)) {
          FF = 1;
          printf("%d\n", j);
          for (int k = j; k < j + ind; k++) arr[k] = M;
          update(1, 0, L + 101, j, j + ind - 1, M);
          break;
        }
        if (arr[j]) last = j;
      }
      if (!FF) printf("-1\n");
    } else {
      int f = 0;
      for (int j = 0; j < L; j++)
        if (arr[j] == ind) {
          if (!f) {
            f = 1;
            update(1, 0, L + 101, j, j + LL[ind] - 1, 0);
          }
          arr[j] = 0;
        }
    }
  }
}
