#include <bits/stdc++.h>
using namespace std;
long long type, len, b, f, n, pos, last, a[100001], l;
bool findplace;
int main() {
  cin >> len >> b >> f;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%ld", &type);
    if (type == 1) {
      scanf("%ld", &l);
      pos = 0;
      findplace = false;
      while (!findplace && pos < len) {
        findplace = true;
        for (int j = (pos - b > 0 ? pos - b : 0);
             j < (len < pos + l + f ? len : pos + l + f); j++)
          if (a[j] != 0) findplace = false, last = j;
        if (findplace && pos + l <= len)
          for (int j = pos; j < (len < pos + l ? len : pos + l); j++) a[j] = i;
        else
          pos = last + 1 + b;
      }
      if (findplace && pos + l <= len)
        printf("%ld\n", pos);
      else
        printf("%ld\n", -1);
    } else {
      int k;
      scanf("%ld", &k);
      for (int j = 0; j < len + 1; j++)
        if (a[j] == k) a[j] = 0;
    }
  }
  return 0;
}
