#include <bits/stdc++.h>
long hash[200005] = {0};
int main() {
  long n, i, l, b, f, k;
  long s = 0;
  long flag = 0, len;
  long max = 0, last = 0;
  scanf("%ld%ld%ld", &l, &b, &f);
  scanf("%ld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%ld", &flag);
    if (flag == 1) {
      scanf("%ld", &len);
      last = 1;
      for (k = 1, max = 0; k <= l + b + f; k++) {
        if (hash[k]) {
          last = k + 1;
          max = 0;
        } else {
          max++;
          if (max >= len + b + f) break;
        }
      }
      if (k <= l + b + f) {
        printf("%ld\n", last - 1);
        for (k = last + b; k < last + b + len; k++) hash[k] = i;
      } else
        printf("-1\n");
    } else {
      scanf("%ld", &flag);
      for (k = 1; k <= b + l + f; k++)
        if (hash[k] == flag) hash[k] = 0;
    }
  }
  return 0;
}
