#include <bits/stdc++.h>
using namespace std;
int L, b, f, n, t, x, last;
vector<pair<int, int>> segs;
vector<pair<int, int>> cars;
map<int, pair<int, int>> carsMap;
void calSeg() {
  segs.clear();
  for (int i = 0; i < cars.size() - 1; i++) {
    if (cars[i + 1].first - cars[i].first - cars[i].second - b) {
      segs.push_back({cars[i].first + cars[i].second + b,
                      cars[i + 1].first - cars[i].first - cars[i].second - b});
    }
  }
}
int main() {
  cin >> L >> b >> f >> n;
  cars.push_back({-b, 0});
  cars.push_back({L + f, 0});
  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    if (t == 1) {
      calSeg();
      bool flag = false;
      pair<int, int> res;
      for (auto a : segs) {
        if (x + f <= a.second) {
          flag = true;
          res = a;
          break;
        }
      }
      if (flag) {
        res.second = x;
        carsMap[i + 1] = res;
        cars.push_back(res);
        sort(cars.begin(), cars.end());
        cout << res.first << endl;
      } else {
        cout << -1 << endl;
      }
    } else {
      cars.erase(find(cars.begin(), cars.end(), carsMap[x]));
    }
  }
  return 0;
}
