#include <bits/stdc++.h>
using namespace std;
bool d[105000];
int cx[105], cy[105];
int main() {
  int L, b, f, n;
  scanf("%d %d %d %d", &L, &b, &f, &n);
  for (int car = 0; car < n; car++) {
    int z;
    scanf("%d", &z);
    if (z == 1) {
      int len;
      scanf("%d", &len);
      int cnt = b;
      for (int i = 0; i < len + f; i++)
        if (!d[i]) cnt++;
      int need = len + b + f;
      int px = -1;
      for (int i = 0; i <= L - len; i++) {
        if (cnt == need) {
          px = i;
          break;
        }
        if (i - b < 0 || !d[i - b]) cnt--;
        if (!d[i + len + f]) cnt++;
      }
      if (px == -1) {
        printf("-1\n");
        continue;
      }
      cx[car] = px;
      cy[car] = px + len;
      printf("%d\n", px);
      for (int i = cx[car]; i < cy[car]; i++) d[i] = true;
    }
    if (z == 2) {
      int k;
      scanf("%d", &k);
      k--;
      for (int x = cx[k]; x < cy[k]; x++) d[x] = false;
    }
  }
  return 0;
}
