#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, B, F;
  scanf("%d %d %d", &L, &B, &F);
  int N;
  scanf("%d", &N);
  bool P[100005];
  memset(P, true, sizeof(P));
  vector<pair<int, int> > V;
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1) {
      int success = 0;
      for (int j = 0; j <= L - b; j++) {
        bool done = 1;
        int d = B, t = j;
        while (--t > -1 && d--)
          if (!P[t]) {
            done = 0;
            break;
          }
        if (!done) continue;
        for (int k = j; k < j + b; k++)
          if (!P[k]) {
            done = 0;
            break;
          }
        if (done) {
          t = j + b, d = F;
          while (d-- && t < L) {
            if (!P[t]) {
              done = 0;
              break;
            }
            t++;
          }
          if (!done) continue;
          for (int k = j; k < j + b; k++) P[k] = false;
          V.push_back(make_pair(j, j + b));
          printf("%d\n", j);
          success = 1;
          break;
        }
      }
      if (!success) {
        puts("-1");
        V.push_back(make_pair(0, 0));
      }
    } else {
      int j = V[b - 1].first, k = V[b - 1].second;
      for (; j < k; ++j) P[j] = true;
      V.push_back(make_pair(0, 0));
    }
  }
  return 0;
}
