#include <bits/stdc++.h>
using namespace std;
const int Max_L = 100000 + 100, inf = ~0U >> 2;
pair<int, int> Ret[1000];
int main() {
  int L, b, f;
  cin >> L >> f >> b;
  int n;
  cin >> n;
  set<pair<int, int> > S;
  S.insert(pair<int, int>(-inf, -inf));
  S.insert(pair<int, int>(inf, inf));
  for (int i = 0; i < n; i++) {
    int t, len;
    cin >> t >> len;
    if (t == 1) {
      bool ok = false;
      for (typeof(S.begin()) it = S.begin(); it != S.end(); it++) {
        if (it == --S.end()) continue;
        int l = max(it->second + f, 0);
        ++it;
        int r = min(it->first - b, L);
        --it;
        if (r - l >= len) {
          ok = true;
          cout << l << endl;
          Ret[i] = pair<int, int>(l, l + len);
          S.insert(Ret[i]);
          break;
        }
      }
      if (!ok) cout << -1 << endl;
    } else {
      len--;
      S.erase(Ret[len]);
    }
  }
}
