#include <bits/stdc++.h>
using namespace std;
int L, b, f, n;
int main() {
  vector<int> x((int)2e5);
  cin >> L >> b >> f >> n;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int len;
      cin >> len;
      int place = 0, begin = 0;
      bool gotcha = false;
      for (int j = 0; j < L; j++) {
        if (!x[j])
          place++;
        else
          place = 0, begin = j + 1;
        if (place == len + b || (place == len && begin == 0)) {
          if (begin != 0) begin += b;
          bool y = true;
          for (int k = j + 1; k <= j + f; k++)
            if (x[k]) {
              y = false;
              break;
            }
          if (y) {
            v.push_back(make_pair(len, begin));
            for (int z = begin; z < begin + len; z++) x[z] = true;
            cout << begin << endl;
            gotcha = true;
            break;
          }
          begin = j + 1;
        }
      }
      if (!gotcha) {
        v.push_back(make_pair(-1, -1));
        cout << -1 << endl;
      }
    } else {
      int num;
      cin >> num;
      for (int j = v[num - 1].second; j < v[num - 1].second + v[num - 1].first;
           j++)
        x[j] = false;
      v.push_back(make_pair(-1, -1));
    }
  }
  return 0;
}
