#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, b, f;
  cin >> L >> b >> f;
  int n;
  cin >> n;
  vector<bool> P(L + f + b + 1, false);
  vector<int> Q(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    if (x == 1) {
      int cnt = 0;
      bool flag = true;
      for (int j = 0; j < P.size(); ++j) {
        if (P[j])
          cnt = 0;
        else
          ++cnt;
        if (cnt == y + f + b) {
          int p0 = j + 1 - y - f - b;
          if (0 <= p0 && p0 + y <= L) {
            cout << p0 << endl;
            Q[i] = p0 + b;
            for (int k = p0 + b; k < p0 + b + y; ++k) {
              P[k] = true;
            }
            flag = false;
            break;
          }
        }
      }
      if (flag) cout << -1 << endl;
    } else {
      for (int k = Q[y - 1]; P[k]; ++k) {
        P[k] = false;
      }
    }
  }
}
