#include <bits/stdc++.h>
int t[100003] = {0};
int main() {
  int L, b, f, n;
  scanf("%d%d%d%d", &L, &b, &f, &n);
  t[L] = 1000;
  for (int i = 1; i <= n; i++) {
    int req, len;
    scanf("%d%d", &req, &len);
    if (req == 1) {
      bool e = 0;
      for (int a = 0; a < L; a++) {
        if (t[a]) continue;
        int prev = a;
        for (int c = a + 1; c <= L; c++) {
          a = c;
          if (t[c]) {
            if (prev == 0 && c == L && L - prev >= len) {
              for (int j = 0; j < len; j++) t[j] = i;
              printf("0\n");
              e = 1;
            } else if (prev == 0 && c >= len + f) {
              for (int j = 0; j < len; j++) t[j] = i;
              printf("0\n");
              e = 1;
            } else if (c == L && L - prev >= len + b ||
                       c - prev >= len + b + f) {
              for (int j = prev + b; j < prev + b + len; j++) t[j] = i;
              printf("%d\n", prev + b);
              e = 1;
            }
            break;
          }
        }
        if (e) break;
      }
      if (!e) printf("-1\n");
    } else {
      for (int j = 0; j < L; j++)
        if (t[j] == len) t[j] = 0;
    }
  }
}
