#include <bits/stdc++.h>
using namespace std;
void init() {}
struct C {
  int l, r, n;
  C(int l, int r, int n) : l(l), r(r), n(n) {}
};
void solve() {
  int l, b, f;
  cin >> l >> b >> f;
  vector<C> a;
  a.push_back(C(0, 0, -1));
  a.push_back(C(l, l, -1));
  int n;
  cin >> n;
  for (int _n(n), z(0); z < _n; z++) {
    int t, k;
    cin >> t >> k;
    if (t == 1) {
      int ok = 0;
      for (int _n(a.size() - 1), i(0); i < _n; i++) {
        int cl = i == 0 ? 0 : a[i].r + b;
        if (a[i + 1].l - cl >= k + ((i + 1 == a.size() - 1) ? 0 : f)) {
          a.insert(a.begin() + i + 1, C(cl, cl + k, z));
          cout << cl << endl;
          ok = 1;
          break;
        }
      }
      if (!ok) cout << -1 << endl;
    } else {
      for (int _n(a.size()), i(0); i < _n; i++)
        if (a[i].n == k - 1) {
          a.erase(a.begin() + i);
          break;
        }
    }
  }
}
int main() {
  init();
  solve();
  return 0;
}
