#include <bits/stdc++.h>
using namespace std;
const int N = 211111;
const long long base = 33ll;
int dl, dr, n;
set<pair<int, int> > cars;
vector<pair<int, int> > stay;
int main() {
  cin >> n >> dl >> dr;
  cars.insert(make_pair(-N, 0 - dl));
  cars.insert(make_pair(n + dr, N));
  int T;
  cin >> T;
  while (T--) {
    int type;
    cin >> type;
    if (type - 1) {
      int pos;
      cin >> pos;
      cars.erase(stay[pos - 1]);
    } else {
      int len;
      cin >> len;
      for (set<pair<int, int> >::iterator it = cars.begin();;) {
        if (it == cars.end()) break;
        pair<int, int> left = *it;
        ++it;
        pair<int, int> right = *it;
        if (left.second + dl + len + dr <= right.first) {
          pair<int, int> ans =
              make_pair(left.second + dl, left.second + dl + len);
          stay.push_back(ans);
          cars.insert(ans);
          cout << left.second + dl << '\n';
          goto next;
        }
      }
      puts("-1");
    }
    stay.push_back(make_pair(N, N));
  next:;
  }
}
