#include <bits/stdc++.h>
using namespace std;
bool gprintf(int debug, const char *format, ...) {
  if (0 & debug) {
    va_list listpointer;
    va_start(listpointer, format);
    vfprintf(stderr, format, listpointer);
    va_end(listpointer);
    return true;
  } else
    return false;
}
struct Car {
  int left;
  int right;
  int idx;
  bool operator<(const Car &c) const { return left < c.left; }
};
vector<Car> cars;
int L, f, b;
int main() {
  int n;
  int i, k;
  int t, l;
  scanf("%d %d %d", &L, &b, &f);
  scanf("%d", &n);
  for ((k) = (1); (k) <= (n); (k)++) {
    scanf("%d %d", &t, &l);
    if (t == 1) {
      Car c;
      if ((cars).size() == 0) {
        c.left = 0;
        c.right = l;
        if (l <= L) {
          c.idx = k;
          cars.push_back(c);
          printf("0\n");
        } else
          printf("-1\n");
      } else {
        int pos = 0;
        i = 0;
        while (i < (cars).size()) {
          if (pos + l <= cars[i].left) {
            int r = pos + l;
            if (r + f <= cars[i].left) break;
          }
          pos = cars[i].right + b;
          i++;
        }
        if (i >= (cars).size()) {
          if (pos + l > L) pos = -1;
        }
        if (pos != -1) {
          c.left = pos;
          c.right = pos + l;
          c.idx = k;
          cars.push_back(c);
          sort((cars).begin(), (cars).end());
        }
        printf("%d\n", pos);
      }
    } else {
      vector<Car>::iterator iter;
      for (iter = cars.begin(); iter != cars.end(); iter++) {
        if (iter->idx == l) break;
      }
      if (iter != cars.end()) cars.erase(iter);
    }
  }
  return 0;
}
