#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, f;
  cin >> n >> b >> f;
  vector<bool> ok(500000, 0);
  vector<int> dev;
  bool malo = 0;
  vector<pair<int, int> > query;
  int ite;
  cin >> ite;
  for (int i = 0; i < ite; i++) {
    int p, q;
    cin >> p >> q;
    if (p == 1) {
      if (q <= n && count(ok.begin(), ok.begin() + q + f, 1) == 0) {
        for (int j = 0; j < q; j++) ok[j] = 1;
        query.push_back(make_pair(0, q));
        dev.push_back(0);
        continue;
      }
      bool bien = 0;
      for (int j = 0; j + b + q <= n; j++)
        if (!ok[j]) {
          bool can = 0;
          for (int k = j; k < j + b + q + f; k++)
            if (ok[k]) {
              can = 1;
              break;
            }
          if (!can) {
            for (int k = j + b; k < j + b + q; k++) ok[k] = 1;
            dev.push_back(j + b);
            query.push_back(make_pair(j + b, q));
            bien = 1;
            break;
          }
        }
      if (bien == 0) {
        dev.push_back(-1);
        query.push_back(make_pair(0, 0));
      }
    } else {
      q--;
      for (int j = query[q].first; j < query[q].first + query[q].second; j++)
        ok[j] = 0;
      query.push_back(query[q]);
    }
  }
  for (int i = 0; i < dev.size(); i++) cout << dev[i] << endl;
  return 0;
}
