#include <bits/stdc++.h>
using namespace std;
struct car {
  int l, r, id;
  car(int l = 0, int r = 0, int id = 0) : l(l), r(r), id(id){};
};
bool cmp(car a, car b) { return a.l < b.l; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<car> v;
  int L, b, f, n;
  cin >> L >> b >> f;
  cin >> n;
  v.push_back(car(-b, -b));
  v.push_back(car(L + f, L + f));
  for (int i = 1; i <= n; i++) {
    int op, a;
    cin >> op >> a;
    if (op == 1) {
      sort(v.begin(), v.end(), cmp);
      int rear = -1;
      for (int i = 0; i < v.size() - 1; i++) {
        if (v[i + 1].l - v[i].r >= a + b + f) {
          rear = v[i].r + b;
          break;
        }
      }
      if (rear == -1) {
        cout << -1 << endl;
      } else {
        cout << rear << endl;
        v.push_back(car(rear, rear + a, i));
      }
    } else {
      for (vector<car>::iterator it = v.begin(); it != v.end(); it++) {
        if (it->id == a) {
          v.erase(it);
          break;
        }
      }
    }
  }
  return 0;
}
