#include <bits/stdc++.h>
using namespace std;
struct car {
  int pos, len, idx;
};
int L, b, f, n;
vector<car> v;
int main() {
  cin >> L >> b >> f >> n;
  v.emplace_back(car{-b, 0, 0});
  for (int i = 1; i <= n; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int len;
      cin >> len;
      int pos = -1;
      for (int j = 0; j < (int)v.size(); j++)
        if (v[j].pos + v[j].len + b + len <= L &&
            (j == (int)v.size() - 1 ||
             v[j].pos + v[j].len + b + len + f <= v[j + 1].pos)) {
          pos = j;
          break;
        }
      if (pos == -1)
        cout << -1 << endl;
      else {
        v.insert(v.begin() + pos + 1, car{v[pos].pos + v[pos].len + b, len, i});
        cout << v[pos + 1].pos << endl;
      }
    } else {
      int idx;
      cin >> idx;
      for (int j = 0; j < (int)v.size(); j++)
        if (v[j].idx == idx) {
          v.erase(v.begin() + j);
          break;
        }
    }
  }
  return 0;
}
