#include <bits/stdc++.h>
using namespace std;
int L, b, f, n, N;
int Q[210000];
int SUM(int L, int R) {
  int res = 0;
  for (L += N, R += N; L < R; L >>= 1, R >>= 1) {
    if (L & 1) res += Q[L++];
    if (R & 1) res += Q[--R];
  }
  return res;
}
map<int, int> M;
void REF() {
  for (int i = N - 1; i > 0; --i) Q[i] = Q[i * 2] + Q[i * 2 + 1];
}
int main() {
  memset(Q, 0, sizeof(Q));
  scanf("%d%d%d%d", &L, &b, &f, &n);
  N = L + f + b;
  REF();
  for (int ii = 0; ii < n; ++ii) {
    int t, tt;
    scanf("%d%d", &t, &tt);
    if (t == 1) {
      bool F = 0;
      int RES = 0;
      for (int i = b; i <= N; ++i) {
        if (i + tt + f > N) break;
        if (SUM(i - b, i + tt + f) == 0) {
          F = 1;
          for (int j = 0; j < tt; ++j) Q[N + i + j] = ii + 1;
          RES = i - b;
          M[ii + 1] = i;
          break;
        }
      }
      if (F)
        printf("%d\n", RES);
      else
        printf("-1\n");
    } else {
      int ttt = M[tt];
      for (int i = ttt; i < N && Q[i + N] == tt; ++i) Q[N + i] = 0;
    }
    REF();
  }
  return 0;
}
