#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > a;
int main() {
  int L, b, f, n, m, cmd, x;
  cin >> L >> b >> f;
  cin >> n;
  for (int cs = (1); cs <= (n); ++cs) {
    sort((a).begin(), (a).end());
    cin >> cmd >> x;
    if (cmd == 1) {
      if ((a.empty() && x <= L) || (!a.empty() && x + f <= a[0].first.first)) {
        cout << 0 << endl;
        a.push_back(make_pair(make_pair(0, x), cs));
        goto C;
      }
      m = (int)(a).size();
      for (int i = 0; i < (m - 1); ++i)
        if (a[i + 1].first.first - a[i].first.second >= b + f + x) {
          cout << a[i].first.second + b << endl;
          a.push_back(make_pair(
              make_pair(a[i].first.second + b, a[i].first.second + b + x), cs));
          goto C;
        }
      if (m && L - a.back().first.second >= b + x) {
        cout << a.back().first.second + b << endl;
        a.push_back(make_pair(
            make_pair(a.back().first.second + b, a.back().first.second + b + x),
            cs));
        goto C;
      }
      cout << -1 << endl;
    } else {
      for (__typeof((a).begin()) i = ((a).begin()); i != (a).end(); ++i)
        if (i->second == x) {
          swap(*i, a.back());
          a.pop_back();
          goto C;
        }
    }
  C:;
  }
  return 0;
}
