#include <bits/stdc++.h>
using namespace std;
int pl[100010];
int main() {
  memset(pl, 0, sizeof(pl));
  int l, b, f;
  scanf("%d%d%d", &l, &b, &f);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int len;
      scanf("%d", &len);
      int j = 0;
      while (j < l) {
        if (pl[j]) {
          ++j;
        } else {
          int k = j;
          while (k < l && pl[k] == 0) {
            ++k;
          }
          int num = k - j;
          int carl = len;
          if (j) carl += b;
          if (k < l) carl += f;
          if (num >= carl) {
            if (j) {
              printf("%d\n", j + b);
              for (int k = 0; k < len; ++k) {
                pl[j + b + k] = i + 1;
              }
              break;
            } else {
              printf("%d\n", j);
              for (int k = 0; k < len; ++k) {
                pl[j + k] = i + 1;
              }
              break;
            }
          } else {
            j = k;
            continue;
          }
        }
      }
      if (j >= l) {
        printf("-1\n");
        continue;
      }
    } else {
      int car;
      scanf("%d", &car);
      for (int j = 0; j < l; ++j) {
        if (pl[j] == car) {
          pl[j] = 0;
        }
      }
    }
  }
}
