#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 17;
int l, b, f, q;
list<pair<int, int> > a;
list<pair<int, int> >::iterator pos[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> l >> b >> f >> q;
  a.push_back({-b, 0});
  a.push_back({l + f, 0});
  for (int i = 0, t, x; i < q; i++) {
    cin >> t >> x;
    if (t == 2)
      a.erase(pos[x - 1]);
    else {
      int ans = -1;
      for (auto it = next(a.begin()); it != a.end(); it++)
        if (it->first - prev(it)->first - prev(it)->second >= x + b + f) {
          ans = prev(it)->first + prev(it)->second + b;
          pos[i] = a.insert(it, {ans, x});
          break;
        }
      cout << ans << '\n';
    }
  }
  return 0;
}
