#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, b, f, n;
  scanf("%d%d%d%d", &L, &b, &f, &n);
  list<pair<int, int>> free_list;
  free_list.push_back(make_pair(-b, L + b + f));
  pair<int, int> requests[101];
  for (int i = 0; i < n; ++i) {
    int type, param;
    scanf("%d%d", &type, &param);
    if (type == 1) {
      for (auto p = free_list.begin(); p != free_list.end(); ++p) {
        if (p->second >= param + b + f) {
          auto old = *p;
          p->second = b;
          free_list.insert(
              ++p, make_pair(old.first + b + param, old.second - b - param));
          requests[i + 1] = make_pair(old.first + b, param);
          printf("%d\n", old.first + b);
          goto found;
        }
      }
      puts("-1");
      continue;
    found:;
    } else {
      const auto pos = requests[param];
      for (auto p = free_list.begin(); p != free_list.end(); ++p) {
        if (p->first + p->second == pos.first) {
          auto q = p;
          ++q;
          p->second += pos.second + q->second;
          free_list.erase(q);
        }
      }
    }
  }
}
