#include <bits/stdc++.h>
using namespace std;
inline void A() {
  int n;
  cin >> n;
  for (int i = 1, x = 1; i < n; ++i) {
    x = (x + i) % n;
    if (x == 0) x = n;
    cout << x << " ";
  }
}
inline void B() {
  map<string, string> mapa;
  mapa["S"] = "01234";
  mapa["M"] = "12034";
  mapa["L"] = "23140";
  mapa["XL"] = "34210";
  mapa["XXL"] = "43210";
  string sz[5] = {"S", "M", "L", "XL", "XXL"};
  int s[5], k;
  for (int i = 0; i < 5; ++i) cin >> s[i];
  cin >> k;
  vector<int> v(k);
  std::string q;
  for (int i = 0; i < k; ++i) {
    cin >> q;
    for (int i = 0; i < 5; ++i) {
      int ind = mapa[q][i] - 48;
      if (s[ind] > 0) {
        cout << sz[ind] << endl;
        s[ind]--;
        break;
      }
    }
  }
}
inline void C() {
  int n, t = 0, res = 1000 * 1000 * 1000;
  string s;
  cin >> n >> s;
  for (int i = 0; i < (int)s.size(); t += s[i++] == 'T')
    ;
  for (int i = 0; i < (int)s.size(); ++i) {
    int z = 0;
    for (int j = 0; j < t; ++j) {
      int pos = (i + j) % s.size();
      z += s[pos] == 'H';
    }
    res = min(z, res);
  }
  cout << res;
}
inline void D() {
  int L, f, b, n, q, x;
  cin >> L >> b >> f >> n;
  vector<char> u(L + f + b, 0);
  for (int i = 0; i < n; ++i) {
    cin >> q >> x;
    if (q == 1) {
      int sz = 0, st = b, ok = 0;
      for (int k = 0; k < (int)u.size(); ++k) {
        if (u[k] == 0) {
          ++sz;
          if (sz >= x + f + b) {
            cout << st - b << endl;
            for (int j = st, c = 0; c < x; ++j, ++c) u[j] = i + 1;
            ok = 1;
            break;
          }
        } else {
          sz = 0;
          st = k + 1 + b;
        }
      }
      if (ok == 0) cout << -1 << endl;
    } else {
      for (int j = 0; j < (int)u.size(); ++j)
        if (u[j] == x) u[j] = 0;
    }
  }
}
inline void E() {}
inline void F() {}
inline void G() {}
int main() {
  D();
  return 0;
}
