#include <bits/stdc++.h>
using namespace std;
class Data {
 public:
  int l, r, num;
  Data() {}
  Data(int a, int b, int c) {
    l = a;
    r = b;
    num = c;
  }
  bool operator<(const Data& a) const { return l < a.r; }
};
vector<Data> a;
int main() {
  int L, b, f, n, q, k;
  cin >> L >> b >> f >> n;
  for (int(qwe) = 0; (qwe) < (n); ++(qwe)) {
    cin >> q >> k;
    if (q == 2) {
      for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
        if (i->num == k) {
          a.erase(i);
          break;
        }
    } else {
      bool ok = 0;
      int l = 0;
      int r = L - k;
      if (!a.empty()) r = a[0].l - k - f;
      if (l <= r) {
        a.insert(a.begin(), Data(l, l + k, qwe + 1));
        cout << l << endl;
        continue;
      }
      for (int i = 0; i < ((int)(a).size()) - 1; ++i)
        if (a[i].r + b <= a[i + 1].l - f - k) {
          cout << a[i].r + b << endl;
          a.insert(a.begin() + i + 1,
                   Data(a[i].r + b, a[i].r + b + k, qwe + 1));
          ok = 1;
          break;
        }
      if (ok) continue;
      r = L - k;
      l = 0;
      if (!a.empty()) l = a.back().r + b;
      if (l <= r) {
        a.push_back(Data(l, l + k, qwe + 1));
        cout << l << endl;
      } else
        cout << "-1\n";
    }
  }
  return 0;
}
