#include <bits/stdc++.h>
int l[100 + 10] = {0}, r[100 + 10] = {0}, t = 0;
int num[100 + 10] = {0};
inline void right(int k) {
  int i;
  ++t;
  for (i = t; i > k; --i) l[i] = l[i - 1], r[i] = r[i - 1], num[i] = num[i - 1];
}
inline void left(int k) {
  int i;
  --t;
  for (i = k - 1; i <= t; ++i)
    l[i] = l[i + 1], r[i] = r[i + 1], num[i] = num[i + 1];
}
int main() {
  int len, b, f;
  int n, i, q;
  int flag, a;
  bool ok;
  scanf("%d%d%d", &len, &b, &f);
  scanf("%d", &n);
  for (q = 1; q <= n; ++q) {
    scanf("%d%d", &flag, &a);
    if (flag == 1) {
      if ((!t && a <= len) || a + f <= l[1]) {
        right(1);
        l[1] = 0, r[1] = a;
        num[1] = q;
        printf("%d\n", 0);
      } else {
        ok = 0;
        for (i = 1; i < t && !ok; ++i)
          if (a + b + f <= l[i + 1] - r[i]) {
            ok = 1;
            right(i + 1);
            l[i + 1] = r[i] + b;
            r[i + 1] = l[i + 1] + a;
            num[i + 1] = q;
            printf("%d\n", l[i + 1]);
          }
        if (!ok) {
          if (r[t] + b + a <= len) {
            ++t;
            l[t] = r[t - 1] + b;
            r[t] = l[t] + a;
            num[t] = q;
            printf("%d\n", l[t]);
          } else
            printf("-1\n");
        }
      }
    } else {
      for (i = 1; i <= t; ++i)
        if (num[i] == a) left(i + 1);
    }
  }
  return (0);
}
